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 for 'hybrid' queries in java client #525

Closed
ksingh17i opened this issue Dec 21, 2023 · 8 comments
Closed

[FEATURE] Support for 'hybrid' queries in java client #525

ksingh17i opened this issue Dec 21, 2023 · 8 comments

Comments

@ksingh17i
Copy link

Is your feature request related to a problem?
Yes, OpenSearch SearchSourceBuilder does not allow hybrid search queries (we are using both query and knn search fields together) throwing NamedObjectNotFoundException with the error message unknown field [hybrid]. We can run the DSL query on the console, but the query builder is unable to parse the same with the java client.

What solution would you like?
We would like to have hybrid query support with the Java client. Probably a HybridPlugin such as KNNPlugin to support the hybrid search queries.

What alternatives have you considered?
We are highly relying on the core library for text and semantic search. We are currently blocked because of missing hybrid support. Implementation of alternatives will be a ground-up work for us and will add additional complexity.

Do you have any additional context?
Query used for testing

{
  "query": {
    "hybrid": {
      "queries": [
        {
          "term": {
            "field_name_1": "Foo bar"
          }
        },
        {
          "knn": {
            "vector_field_name": {
              "vector":  [...],
              "k": 2
            }
          }
        }
      ]
    }
  },
  "size": 10
}

Exception:

org.opensearch.core.common.ParsingException: unknown query [hybrid] 
at org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder(AbstractQueryBuilder.java:338) ~[opensearch-2.11.1.jar:2.11.1] 
at org.opensearch.search.builder.SearchSourceBuilder.parseXContent(SearchSourceBuilder.java:1200) ~[opensearch-2.11.1.jar:2.11.1] 
at org.opensearch.search.builder.SearchSourceBuilder.parseXContent(SearchSourceBuilder.java:1130) ~[opensearch-2.11.1.jar:2.11.1] 
at com.a.b.c.Helper.parseRequest(Helper.java:61) [classes/:?] 
.
.
.
Caused by: org.opensearch.core.xcontent.NamedObjectNotFoundException: [3:15] unknown field [hybrid] 
at org.opensearch.core.xcontent.NamedXContentRegistry.parseNamedObject(NamedXContentRegistry.java:164) ~[opensearch-core-2.11.1.jar:2.11.1] 
at org.opensearch.core.xcontent.AbstractXContentParser.namedObject(AbstractXContentParser.java:429) ~[opensearch-core-2.11.1.jar:2.11.1] 
at org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder(AbstractQueryBuilder.java:330) ~[opensearch-2.11.1.jar:2.11.1]
@ksingh17i ksingh17i changed the title [FEATURE] [FEATURE] Support for 'hybrid' queries in java client Dec 21, 2023
@navneet1v navneet1v transferred this issue from opensearch-project/k-NN Dec 29, 2023
@navneet1v
Copy link
Collaborator

Moved issue to neural repo as hybrid query clause is provided by neural plugin

@ksingh17i
Copy link
Author

ksingh17i commented Jan 16, 2024

Update: we are currently using opensearch-rest-high-level-client version 2.11.0 and opensearch-knn plugin version 2.11.0.0

@navneet1v
Copy link
Collaborator

navneet1v commented Jan 29, 2024

@ksingh17i the opensearch-rest-high-level-client is marked for deprecation and will be removed in 3.0 version of Opensearch. Hence the query clause will not be added in opensearch-rest-high-level-client.

Ref: https://opensearch.org/docs/latest/clients/java-rest-high-level/

The only place where we can add hybrid query clause now is https://github.com/opensearch-project/opensearch-java .

@ksingh17i
Copy link
Author

Any idea by when can we expect hybrid query support in https://github.com/opensearch-project/opensearch-java

@ksingh17i
Copy link
Author

@navneet1v any update on this?

@vibrantvarun
Copy link
Member

@ksingh17i we have merged the PR for the support of hybrid query in java client.

@navneet1v
Copy link
Collaborator

@ksingh17i the release issue on the Opensearch java client is also created: opensearch-project/opensearch-java#868 More details on the release will be available there.

@vibrantvarun vibrantvarun moved this from Backlog to 2.13.0 in Vector Search RoadMap Feb 22, 2024
@navneet1v
Copy link
Collaborator

@ksingh17i the java client has been released with the hybrid query. As this issue is resolved: opensearch-project/opensearch-java#868

Artifacts can be found here: https://repo1.maven.org/maven2/org/opensearch/client/opensearch-java/2.9.0/

Resolving the issue.

@github-project-automation github-project-automation bot moved this from 2.13.0 to ✅ Done in Vector Search RoadMap Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants