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

Fix: nested neural_sparse search throws error if model_id not supplied and default_model_id is configured #872

Closed
wants to merge 1 commit into from

Conversation

jdnvn
Copy link

@jdnvn jdnvn commented Aug 22, 2024

Description

Adds a conditional for default model id support when validating model id presence in NeuralSparseQueryBuilder. This will prevent the query_text and model_id cannot be null error. Also splits up the errors to make it more clear which is null.

Related Issues

Resolves #871

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@jdnvn
Copy link
Author

jdnvn commented Aug 22, 2024

Not sure if this solution is correct, but figured I'd give it a shot. Let me know and I can add some tests. I also wasn't sure how to test this in my local OpenSearch container, so any guidance would be much appreciated.

@navneet1v
Copy link
Collaborator

Not sure if this solution is correct, but figured I'd give it a shot. Let me know and I can add some tests. I also wasn't sure how to test this in my local OpenSearch container, so any guidance would be much appreciated.

@jdnvn thanks for raising the PR. Adding few maintainers who can help in neural sparse. @zane-neo , @yuye-aws, @model-collapse

@@ -376,16 +376,24 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
}

private static void validateForRewrite(String queryText, String modelId) {
if (StringUtils.isBlank(queryText) || StringUtils.isBlank(modelId)) {
if (StringUtils.isBlank(modelId) && !isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport only checks whether the default model id feature is supported in the current cluster by OpenSearch version. Have you checked that default model id has been configured?

@zhichao-aws
Copy link
Member

Please don't fix this issue via this approach, it won't fix the problem, the ml-commons will still throw exception because the passed in model id is null. The root cause is the compound query visitor logics in OpenSearch core, example: opensearch-project/OpenSearch#14739. And for your case here I think it's the missing of sub-visitor in function_score query. Let's discuss the problem in #871

@yuye-aws
Copy link
Member

Let me know and I can add some tests. I also wasn't sure how to test this in my local OpenSearch container, so any guidance would be much appreciated.

You can follow this guide: https://github.com/opensearch-project/OpenSearch/blob/main/TESTING.md

@yuye-aws
Copy link
Member

@zhichao-aws and @conggguan has more context on this PR. Can you help review?

@zhichao-aws
Copy link
Member

@zhichao-aws and @conggguan has more context on this PR. Can you help review?

The bug is not fixed from neural-search. It's fixed by modifying the compound query visitor in core

@yuye-aws
Copy link
Member

@zhichao-aws and @conggguan has more context on this PR. Can you help review?

The bug is not fixed from neural-search. It's fixed by modifying the compound query visitor in core

I see. We need a PR in core to fix the visitor.

@jdnvn
Copy link
Author

jdnvn commented Aug 25, 2024

Thanks guys, I opened up this PR in OpenSearch core opensearch-project/OpenSearch#15404

@jdnvn jdnvn closed this Aug 25, 2024
@jdnvn jdnvn deleted the main branch August 25, 2024 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Cannot make use of default_model_id in neural_sparse query type
4 participants