opensearch-project / opensearch-net

OpenSearch .NET Client
Apache License 2.0
107 stars 49 forks source link

[BUG] ModelId should be optional for NeuralQuery #832

Open jamesjhhan opened 1 month ago

jamesjhhan commented 1 month ago

What is the bug?

If the ModelId is not provided for a Neural query, it is considered conditionless and ignored. However, this is not a correct implementation since a default ModelId can be configured through a search pipeline. https://opensearch.org/docs/latest/search-plugins/search-pipelines/neural-query-enricher/

How can one reproduce the bug?

Specify a NeuralQuery without the ModelId

What is the expected behavior?

If ModelId is not provided, it should execute the query.

What is your host/environment?

Windows, 10

Do you have any screenshots?

Do you have any additional context?

The fix I tested appears to be simple. Just update line 54 in NeuralQuery.cs to remove the "string.IsNullOrEmpty(q.ModelId) condition.

dblock commented 1 month ago

Much of this code is generated from spec. Check whether the spec for this field in https://github.com/opensearch-project/opensearch-api-specification is correct, if not that's where the fix should go. If it's not generated, contribute a fix to both with a unit test here?