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] Support Boosting for Neural Query #743

Open
yudhiesh opened this issue Nov 24, 2023 · 1 comment
Open

[FEATURE] Support Boosting for Neural Query #743

yudhiesh opened this issue Nov 24, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@yudhiesh
Copy link

yudhiesh commented Nov 24, 2023

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.

@yudhiesh yudhiesh added enhancement New feature or request untriaged labels Nov 24, 2023
@dblock dblock removed the untriaged label Dec 4, 2023
@yudhiesh
Copy link
Author

Just to add I am also querying an alias but trying to boost a specific index within the alias.

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

2 participants