Skip to content

[BUG] terms query on wildcard field returns wrong result #15571

@HUSTERGS

Description

@HUSTERGS

Describe the bug

when apply terms query on wildcard field, the result is not correct

Related component

Search

To Reproduce

  1. Create a simple index contains wildcard field
    PUT terms_query_index
    {
      "mappings": {
        "properties": {
          "wild": {
            "type": "wildcard"
          }
        }
      }
    }
    
  2. Insert data
    POST terms_query_index/_doc
    {
      "wild": "term"
    }
    
  3. Search wildcard field with terms query
    GET terms_query_index/_search
    {
      "query": {
        "terms": {
            "wild": ["term"]
        }
      }
    }
    
    Search Result:
    {
        "took": 37,
        "timed_out": false,
        "_shards": {
            "total": 1,
            "successful": 1,
            "skipped": 0,
            "failed": 0
        },
        "hits": {
            "total": {
                "value": 0,
                "relation": "eq"
            },
            "max_score": null,
            "hits": []
        }
    }
    

Expected behavior

the terms query should return the inserted data, instead of nothing

Additional Details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions