opensearch-project / opensearch-project/opensearch-java
[FEATURE] Support Boosting for Neural Query
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
Is your feature request related to a problem?
A clear and concise description of what the problem is, e.g. I'm always frustrated when [...].
Currently, when using semantic search I have an issue where it perform poorly over exact keyword search with boosting for situations where I would like to artificially boost certain indices due to businees goals.
Sample Output:
{
"took": 29,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 28,
"relation": "eq"
},
"max_score": 0.66891545,
"hits": [
{
"_index": "A",
"_id": "A-hjHkg4JVoxyrjVaY1T1fC",
"_score": 0.66891545,
},
{
"_index": "A",
"_id": "A-4IIkZsGqs6AAGNJBPxFG2q",
"_score": 0.66891545,
},
{
"_index": "A",
"_id": "A-PrFcKYXMGHTF6DSZ15zxw",
"_score": 0.6600258,
},
{
"_index": "B",
"_id": "B-ppZ_YYBf08C9I8emn4W",
"_score": 0.6593717,
},
{
"_index": "A",
"_id": "A-55mffVK1TqNteVpb6mri5d",
"_score": 0.659091,
}
]
}
}
In this scenario I would like to apply a constant boost of 0.1 to the _score of index B .
I tried doing it within the Java Client like so:
NeuralQuery neuralQuery = new NeuralQuery.Builder()
.field(...)
.queryText(...)
.modelId(MODEL_ID)
.k(KNN_TOP_K)
.build();
Query query = new Query.Builder()
.neural(neuralQuery)
.build();
List<Map<String, Double>> indicesToBoost = List.of(Map.of(
"B", 0.1
));
var searchResponse = openSearchJavaClient.search(
s -> s.index(UniversalSearchCategory.SEMANTIC_OFFERS.getIndexName())
.from(param.getOffset())
.size(param.getLimit())
.sort(sortOptions)
.query(query)
.source(sourceConfig)
.indicesBoost(indicesToBoost)
, Object.class
);
But the scores do not get boosted at all.
What solution would you like?
A clear and concise description of what you want to happen.
I would like to see the score of the index B increase by 0.1.
{
"_index": "B",
"_id": "B-ppZ_YYBf08C9I8emn4W",
"_score": 0.7593717,
}
What alternatives have you considered?
A clear and concise description of any alternative solutions or features you've considered.
Do you have any additional context?
Add any other context or screenshots about the feature request here.
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 by tracing the Java client's NeuralQuery, Query, and search request handling, including the indicesBoost option shown in the issue. Determine how boosting is expected to affect neural-query scores, then verify that an index B result receives the requested 0.1 increase in a representative search response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100