opensearch-project / opensearch-project/opensearch-java

[FEATURE] Boost functionality support for MultiMatchQuery

Open
#650 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
165
Forks
250
Avg merge
1d 18h
Merged PRs (30d)
26

Description

We are porting from ES 6.X to OS 2.X. In the old org.elasticsearch.index.query.MultiMatchQueryBuilder there is a field method which accepts field name and the boost value. So each field can be boosted as desired. But with the new org.opensearch.client.opensearch._types.query_dsl.MultiMatchQuery.Builder we don't have a method like this. So we can't set boost values.

I believe having same old field method is required to set the boost values for each field. See below the old method code

    if (Strings.isEmpty(field)) {
      throw new IllegalArgumentException("supplied field is null or empty.");
    } else {
      this.fieldsBoosts.put(field, boost);
      return this;
    }
  }

Although I didn't see any documentation about it but I suspect setting boost values on a field can be achieved via updating the field name. So boost a field named "title" we can add field like this. Even we have this feature should we also have a method for field boost? I think we should.
multiMatchQueryBuilder.fields("title^10")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the org.opensearch.client.opensearch._types.query_dsl.MultiMatchQuery.Builder and compare its field handling with the old org.elasticsearch MultiMatchQueryBuilder.field(String, float) method shown here. Check whether fields("title^10") already provides equivalent behavior; done means the supported approach for per-field boost values is clear and, if needed, the builder exposes the requested capability.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.