Skip to content

[BUG] neural_query_enricher does not set the model ID, if the neural query is nested. #1269

@swolehee

Description

@swolehee

What is the bug?

When the neural query is nested, the neural_field_default_id from the neural_query_enricher isn't set for request's model_id. This leads to the error: "type": "null_pointer_exception", "reason": "modelId is marked non-null but is null" if we don't explicitly pass the model_id.

How can one reproduce the bug?

  • create a search pipeline with a neural_query_enricher
  • perform a function_score query with the search pipeline, where the neural query (without explicitly passing the model_id) is nested inside it.

What is the expected behavior?

  • model_id is inferred from neural_query_enricher in the search pipeline

What is your host/environment?

  • OpenSearch 2.17

Do you have any screenshots?

Our search pipeline:

{
  "default_model_pipeline": {
    "request_processors": [
      {
        "neural_query_enricher": {
          "neural_field_default_id": {
            "searchTextEmbedding": "aQJlv5QBnZfSLyF3MObN"
          }
        }
      }
    ]
  }
}

Below works:

POST routing-events-2025-04-11/_search?search_pipeline=default_model_pipeline
{
    "query": {
        "neural": {
            "searchTextEmbedding": {
                "query_text": "test",
                "k": 150
            }
        }
    }
}

Below fails with the error "modelId is marked non-null but is null"

POST routing-events-2025-04-11/_search?search_pipeline=default_model_pipeline
{
    "query": {
        "function_score": {
            "query": {
                "neural": {
                    "searchTextEmbedding": {
                        "query_text": "test",
                        "k": 150
                    }
                }
            },
            "functions": [
                {
                    "gauss": {
                        "eventHeader.timestamp": {
                            "origin": "now",
                            "scale": "30d",
                            "offset": "10d",
                            "decay": 0.5
                        }
                    }
                }
            ],
            "boost_mode": "multiply"
        }
    }
}

Do you have any additional context?

Add any other context about the problem.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions