Wildcard query no results, but wildcard in query_string works OK

I am running ES 5.3.3.
I've got a document field name, value: L-tryp-something which I am trying to find.

This query gives no result:
"wildcard" : { "name" : { "wildcard" : "L-tryp*", "boost" : 2.0 } }

However this works fine:

 "query_string" : {
                "default_field": "name",
                "query": "L-Tryp*",
                "boost" : 2.0
              }

Any idea why is that?

Here is full curl command set to create index, index a document, then execute 2 searches:

curl -XPUT "http://localhost:9200/test" -d '{"mappings": {
      "substance": {
        "properties": {       
          "name": {
            "type": "text",
            "analyzer":"lowercase_keyword_analyzer",            
            "fields": {
              "nGram": {
                "type": "text",
                "analyzer": "lowercase_ngram_keyword_analyzer"
              }
            }
          }
        }
      }
    }, "settings": {
      "index": {
        "analysis": {
          "filter": {
            "ngram": {
              "type": "nGram",
              "min_gram": "1",
              "max_gram": "10"
            }
          },
          "analyzer": {
            "lowercase_ngram_keyword_analyzer": {
              "filter": [
                "lowercase",
                "ngram"
              ],
              "tokenizer": "keyword"
            },
            "lowercase_keyword_analyzer": {
              "filter": [
                "lowercase"
              ],
              "tokenizer": "keyword"
            }
          }
        }
      }
    }}'


curl -XPUT "localhost:9200/test/substance/2320" -H 'Content-Type: application/json' -d'
{    
    "name" : "L-tryp-something"    
}
'


curl -XPOST "localhost:9200/test/_search" -d'
{
    "query": {
        "wildcard" : { "name" : { "wildcard" : "L-tryp*", "boost" : 2.0 } }
    }
}
'

curl -XPOST "localhost:9200/test/_search" -d'
{
   "query": {
      "query_string" : {
        "default_field": "name",
        "query": "L-Tryp*",
        "boost" : 2.0
      }    
  }
}'

Right the answer is that wildcard query doesn't use the search analyzer and as a result doesn't run the lowercase filter on the search term. Since the index on name is lowercased there are no results starting from capital F as in the above example.
The query_string by default does lowercase the search string, so in fact it has its own analyzer which works just fine with the the wildcard.

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