# Wildcard query no results, but wildcard in query\_string works OK

**URL:** https://discuss.elastic.co/t/wildcard-query-no-results-but-wildcard-in-query-string-works-ok/152471
**Category:** Elasticsearch
**Created:** [October 15, 2018, 10:33am UTC](https://discuss.elastic.co/t/wildcard-query-no-results-but-wildcard-in-query-string-works-ok/152471 "2018-10-15T10:33:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tomekit](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@tomekit](https://discuss.elastic.co/u/tomekit)
#### Post date: [October 15, 2018, 10:33am UTC](https://discuss.elastic.co/t/wildcard-query-no-results-but-wildcard-in-query-string-works-ok/152471/1 "2018-10-15T10:33:41Z")

</div>

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
      }    
  }
}'
```

---

<div class="post-metadata">

### Author: ![tomekit](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@tomekit](https://discuss.elastic.co/u/tomekit)
#### Post date: [October 15, 2018, 11:11am UTC](https://discuss.elastic.co/t/wildcard-query-no-results-but-wildcard-in-query-string-works-ok/152471/2 "2018-10-15T11:11:53Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 12, 2018, 11:22am UTC](https://discuss.elastic.co/t/wildcard-query-no-results-but-wildcard-in-query-string-works-ok/152471/3 "2018-11-12T11:22:59Z")

</div>

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