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

Adding support for Radial Search in Neural Query #1226

Closed
manabendrapaul opened this issue Oct 11, 2024 · 3 comments · Fixed by #1235
Closed

Adding support for Radial Search in Neural Query #1226

manabendrapaul opened this issue Oct 11, 2024 · 3 comments · Fixed by #1235

Comments

@manabendrapaul
Copy link

What/Why

What are you proposing?

Adding support for Radial Search in Neural Query

What users have asked for this feature?

Users connecting to Opensearch using Java Client

What problems are you trying to solve?

Currently the Java SDK only takes 'k' as part of Neural Query, whereas from Opensearch 2.15, we can pass min_score / max_distance as part of neural query. But I dont see these options with Java Client.

What is the developer experience going to be?

Devlopers can directly use that feature instead of moving to GenericClient.

Are there any security considerations?

No

Are there any breaking changes to the API

No

What is the user experience going to be?

Developers can build queries with ease.

Are there breaking changes to the User Experience?

No Breaking changes

Why should it be built? Any reason not to?

To make it in sync with latest Radial search features in Opensearch 2.15 features.

What will it take to execute?

Some enhancements to NeuralSearch query builders.

Any remaining open questions?

No

@dblock
Copy link
Member

dblock commented Oct 11, 2024

I would start by checking whether this is supported in https://github.com/opensearch-project/opensearch-api-specification (might need changes, and a test). We are working on code generation from spec #366 so this will get covered this way.

@manabendrapaul
Copy link
Author

Thanks for your reply.

But, Won't NeuralQuery also support this features? Currently, we can set the value of 'k' while forming a neural query.

e.g. For the below query:

"query": {
        "hybrid": {
          "queries": [
            {
              "match": {
                "distilled_content": {
                  "query": "what is the plants game"
                }
              }
            },
            {
              "neural": {
                "article_embedding": {
                  "query_text": "what is the plants game",
                  "model_id": "9KvnbZABfxmyMZwietnR",
                  "k": 5
                }
              }
            }
          ]
        }
      }

We can write using Java client like this:

Query.of(h -> h
				.hybrid(q -> q
				.queries(Arrays.asList(
						new MatchQuery.Builder().field(DISTILLED_CONTENT).query(FieldValue.of(request.getQuery())).build().toQuery(),
						new NeuralQuery.Builder().field(ARTICLE_EMBEDDING).queryText(request.getQuery()).modelId("9KvnbZABfxmyMZwietnR").k(5).build().toQuery()))));

But, if I try to use radial search options of min_score or max_distance, I cant find similar options with Java Client.
e.g.

"query": {
    "neural": {
      "article_embedding": {
        "query_text": "plants vs. zombies",
        "model_id": "9KvnbZABfxmyMZwietnR",
        "min_score": "0.50"
      }
    }
  }

@Xtansia
Copy link
Collaborator

Xtansia commented Oct 23, 2024

Support for this was added as part of version 2.16.0 of the client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants