opensearch-project / opensearch-project/opensearch-java
Unable to create gauss decay function in java client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
What is the bug?
Unable to create a function score query using decay functions(gauss, linear, exp)
How can one reproduce the bug?
One should have a field in opensearch with java mapping as double ( field : rating)
Create a function score query and add a gauss function or any decay function and run a query. One should get 400 bad request error in all possible combinations.
What is the expected behavior?
A query should produce a result having _score of documents adjusted as per the decay function.
What is your host/environment?
AWS ECS Fargate
Do you have any screenshots?
Do you have any additional context?
query snippet
{
"filter": {
"bool": {
"must": {
"query_string": {
"fields": [
"name"
],
"query": "akshay"
}
}
}
},
"gauss": {
"rating": {
"decay": 0.85,
"offset": "0",
"origin": "10",
"scale": "0.5"
}
},
"weight": 999
}
Java Code
var ratingScore = new FunctionScore.Builder().gauss(decay -> decay.field("rating").placement(
dp -> dp.origin(JsonData.of("10")).scale(JsonData.of("5")))
.weight(999d).filter(QueryUtils.getQueryStringQuery("akshay", "name")._toQuery())).build();
fsq.functions(List.of(popularityScore, ratingScore))
.query(boolQueryBuilder.build()._toQuery())
.scoreMode(FunctionScoreMode.Max)
.boostMode(FunctionBoostMode.Replace);
fsq -> instance of function score query builder
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Java FunctionScore builder snippet and the JSON query shown in the issue, then reproduce a function score query using the gauss decay function on a double rating field. Compare the serialized request with the query accepted by OpenSearch and capture the 400 response. Done means gauss, linear, and exp decay functions can run and adjust document scores without a bad request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100