Skip to content

[BUG] neural query yields inconsistent results when searching against aliases/many indexes #18232

Open
@swolehee

Description

@swolehee

Describe the bug

When specifying search_pipeline query parameter in a search against an alias, the result comes varies greatly. For example, in our issue, the same query can return 5117 hits, 294 hits, or 0 hits.

However, when I perform the same query on individual indexes that is in the alias, the result does not vary.

Related component

Search

To Reproduce

  • Create a search pipeline - for us, it was a pipeline with neural_query_enricher
{
  "default_model_pipeline": {
    "request_processors": [
      {
        "neural_query_enricher": {
          "neural_field_default_id": {
            "searchTextEmbedding_nomic-embed-text-v1-5": "sdBJwJQBMYQjvGaa1r_u"
          }
        }
      }
    ]
  }
}
  • Create indexes with a mapping that contains the field searchTextEmbedding_nomic-embed-text-v1-5. Add the index in an alias
        "searchTextEmbedding_nomic-embed-text-v1-5": {
          "type": "knn_vector",
          "dimension": 768,
          "method": {
            "engine": "faiss",
            "space_type": "l2",
            "name": "hnsw",
            "parameters": {
              "ef_construction": 100,
              "m": 16
            }
          }
        },
  • Add events into the indexes

  • Perform a search with the pipeline against the alias

GET routing-events-alias/_search?routing=customer123&search_pipeline=default_model_pipeline
{
  "size": 20,
  "query": {
    "neural": {
      "searchTextEmbedding_nomic-embed-text-v1-5": {
        "query_text": "dinner",
        "k": 300,
        "filter": {
          "bool": {
            "must": [
              {
                "range": {
                  "eventHeader.timestamp": {
                    "gte": 1743546731000,
                    "lte": 1746138731000
                  }
                }
              },
              {
                "term": {
                  "eventHeader.customerId": "customer123"
                }
              }
              }
            ]
          }
        }
      }
    }
  },
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    },
    {
      "eventHeader.timestamp": {
        "order": "desc"
      }
    }
  ],
  "_source": {
    "excludes": [
      "searchTextEmbedding_nomic-embed-text-v1-5"
    ]
  }
}
  • Perform the same search with the pipeline against an index in the alias
GET routing-events-2025-05-01/_search?search_pipeline=default_model_pipeline
{
   ...
}

Expected behavior

Expected the results when searching against the alias to yield consistent result.

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: N/A
  • AWS OpenSearch
  • Version: OpenSearch 2.17

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SearchSearch query, autocomplete ...etcbugSomething isn't workinguntriaged

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions