Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Boost functionality support for MultiMatchQuery #650

Open
KaganAddSearch opened this issue Oct 4, 2023 · 6 comments
Open

[FEATURE] Boost functionality support for MultiMatchQuery #650

KaganAddSearch opened this issue Oct 4, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@KaganAddSearch
Copy link

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")

@KaganAddSearch KaganAddSearch added enhancement New feature or request untriaged labels Oct 4, 2023
@VachaShah VachaShah changed the title [FEATURE] [FEATURE] Boost functionality support for MultiMatchQuery Oct 4, 2023
@VachaShah
Copy link
Collaborator

@KaganAddSearch Thank you for raising this issue!

As I understand, you are suggesting one of the 2 options:

  1. Add boost field support in MultiMatchQueryBuilder - which is a code change on this repo.
  2. Try to use multiMatchQueryBuilder.fields("title^10") to boost - have you tried this out?

@KaganAddSearch
Copy link
Author

@VachaShah We have tried multiMatchQueryBuilder.fields("title^10"). It seems to be working. It is a usable solution but this should be documented. So users don't have to guess this.

@VachaShah
Copy link
Collaborator

Thats great @KaganAddSearch! Thank you for getting back on this.

Definitely we should add a test and a working sample in https://github.com/opensearch-project/opensearch-java/tree/main/samples for documentation along with the guides. Would be willing to take this up?

@pranishd1
Copy link

pranishd1 commented Oct 21, 2023

Hi @VachaShah , I would like to work in this issue. Can you please assign it to me?

@dblock
Copy link
Member

dblock commented Dec 4, 2023

@pranishd1 Are you still (wanting to) work(ing) on this?

@pranishd1
Copy link

@pranishd1 Are you still (wanting to) work(ing) on this?

@dblock , sorry I am occupied right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants