Discrepancy (bug or misunderstanding) in how simple_query_string handles queries?

I have a field, let's call it MyField mapped as a keyword type.
If I search using simple_query_string, like so:

GET /my-index/_search
{
  "from": 0,
  "size": 1000,
  "query": {
    "bool": {
      "filter": [
        {
          "simple_query_string": {
            "query": "l120   2007:09:11 98c57u495891",
            "fields": [
              "MyField^1.0"
            ],
            "flags": -1,
            "default_operator": "and",
            "analyze_wildcard": true,
            "auto_generate_synonyms_phrase_query": true,
            "fuzzy_prefix_length": 0,
            "fuzzy_max_expansions": 50,
            "fuzzy_transpositions": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "explain": false,
  "_source": {
    "includes": [],
    "excludes": []
  },
  "track_total_hits": 10000
}

returns no results. But if I search specifically using bool filter:

GET /index/_search
{
    "from": 0,
    "size": 1000,
    "query": {
        "bool": {
            "filter": [
                {
                        "term": {
                            "MyField": "l120   2007:09:11 98c57u495891"
                        }
                }
            ],
            "adjust_pure_negative": true,
            "boost": 1.0
        }
    },
    "explain": false,
    "_source": {
        "includes": [],
        "excludes": []
    },
    "track_total_hits": 10000
}

then I do get results as expected.

Why doesn't the simple_query_string search type give me results?

(es version 7.8.0)
Thanks for any help offered!

this is different between term-level query and full text query:
term-level query is for keyword type and full text query is for text type.
simple_query_string is one for full text query and you can try as follow, it means match_phrase by using \"something\"

 "simple_query_string": {
            "query": "\"l120   2007:09:11 98c57u495891\"",
            "fields": [
              "MyField^1.0"
            ],

Thanks for the explanation, @casterQ, unfortunately the suggestion didn't work.

I'm guessing that if I really want to search across all fields in a consistent manner than I can't mix and match my field types between text and term.

If I want to enjoy the benefits of both, I'll need to change my mapping to:

"MyField": {
    "type": "text",
    "properties": {
        "keyword" : {
            "type": "keyword"
        }
    }
}

and either target MyField or MyField.keyword?

Is there no way to target keyword-type fields with a simple_query_string type field?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.