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] java-client should support FunctionScore with MatchTermQuery #655

Closed
m-hofmann opened this issue Oct 6, 2023 · 6 comments
Closed
Labels
enhancement New feature or request

Comments

@m-hofmann
Copy link

We are trying to use java-client 2.6.0 to build a function score query boosting specific hits on fields. Our query JSON looks like this:

{
  "from": 0,
  "size": 20,
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "should": [
            {
              "match": {
                "some_field": "1234"
              }
            }
          ],
          "minimum_should_match": 1
        }
      },
      "boost_mode": "multiply",
      "score_mode": "sum",
      "functions": [
        {
          "filter": {
            "match": {
              "some_field": "1234"
            }
          },
          "weight": 2
        }
      ]
    }
  }
}

unfortunately the java-client seems to support only specific function "kinds" for the functions block, like random_score or script_score. When we try to instantiate a query using the Java DSL that looks like the above snippet:

FunctionScore functionScore = new FunctionScore.Builder()
   .new ContainerBuilder()
   .filter(query)
   .weight(10.0)
   .build();

an exception org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'Builder.<variant kind> will be thrown.

What solution would you like?

Being able to build a function object combining a (match)query with a weight.

What alternatives have you considered?

We tried to disable API warnings using ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(true) but then serialization of the request in the search client fails.

Therefore we're switching back to the REST highlevel client for now.

@m-hofmann m-hofmann added enhancement New feature or request untriaged labels Oct 6, 2023
@jmontgomery-wbd
Copy link

any updates on this? this is a pretty big miss....

@dblock
Copy link
Member

dblock commented Nov 3, 2023

@jmontgomery-wbd AFAIK nobody is working on this, care to help?

@jmontgomery-wbd
Copy link

@dblock it seems like there is a lot of red tape around contributing. I just pulled and made an update and it seems to have fixed it:
Screen Shot 2023-11-03 at 4 13 13 PM

how can we properly test and merge that?

@dblock
Copy link
Member

dblock commented Nov 6, 2023

@jmontgomery-wbd No tape. Just make a pull request with a passing test that wasn't passing before.

@brianyee-fanatics
Copy link

Also looking for this feature.

@dblock dblock removed the untriaged label Dec 4, 2023
@VachaShah
Copy link
Collaborator

This feature was added in PR #880 and will be released in the upcoming version. Currently the change is available to consume in 2.10.0-SNAPSHOT.

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

5 participants