opensearch-project / neural-search

Plugin that adds dense neural retrieval into the OpenSearch ecosytem
Apache License 2.0
56 stars 58 forks source link

[FEATURE] Results returned from Hybrid Search should respect sorting applied #507

Open ankitas3 opened 8 months ago

ankitas3 commented 8 months ago

Is your feature request related to a problem? Hybrid Search always returns results in the descending order of score. Applying sorting as below has no affect on the results

{
  "query": {
    "hybrid":{
      "queries": [
        <text query>,
        <kNN query>
      ]
    }
  }
  "sort": [
    {
      "title.keyword": {
        "order": "desc"
      }
    }
  ]
}

What solution would you like? Sorting should work as it does with other boolean queries. Results matching the Hybrid query should later be sorted on the basis of sorting applied.

navneet1v commented 7 months ago

Moving this to neural search repo, as the hybrid query clause is in Neural Search repo.

vibrantvarun commented 1 month ago

Hey @ankitas3 Can you share the use case of this problem? We are doing some brainstorming and we need to understand how sorting fits in your usecase.

tsilvafsl commented 3 weeks ago

I am experiencing a problem that might be related.

When performing a hybrid search query with a search_pipeline, the sort tag does not work as expected.

In other words, the sort is being bypassed by search_pipeline and if you remove the search pipeline, the sort works fine in a hybrid query.

In this issue I describe the problem and a reproducible example. https://forum.opensearch.org/t/unable-to-sort-query-results-with-search-pipeline-hybrid-query/19726

Is it possible to make it work with current opensearch?