# Wildcard Not Working as Expected

**URL:** <https://discuss.elastic.co/t/wildcard-not-working-as-expected/70489>\
**Category:** Elasticsearch\
**Created:** [January 3, 2017, 10:46pm UTC](https://discuss.elastic.co/t/wildcard-not-working-as-expected/70489 "2017-01-03T22:46:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![krmathieu](https://avatars.discourse-cdn.com/v4/letter/k/b5e925/32.png) [@krmathieu](https://discuss.elastic.co/u/krmathieu)\
**Post date:** [January 3, 2017, 10:46pm UTC](https://discuss.elastic.co/t/wildcard-not-working-as-expected/70489/1 "2017-01-03T22:46:42Z")

</div>

Why does this query work as expected:

```
{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "query_string" : {
            "query" : "orgs.normalized: UBER"
        }
    }
}
```

But this one does not:

```
{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "query_string" : {
            "query" : "orgs.normalized: UBE*"
        }
    }
}
```

Do I have to do something special because of the widlcard (\*) symbol? The field is set to NOT\_ANALYZED, is that the problem? That is, I can't run wildcard queries against a NOT\_ANALYZED field? Please advise. Thanks.

Kevin

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 4, 2017, 6:07am UTC](https://discuss.elastic.co/t/wildcard-not-working-as-expected/70489/2 "2017-01-04T06:07:58Z")

</div>

Can you remove the space after the fieldname?

---

<div class="post-metadata">

**Author:** ![krmathieu](https://avatars.discourse-cdn.com/v4/letter/k/b5e925/32.png) [@krmathieu](https://discuss.elastic.co/u/krmathieu)\
**Post date:** [January 4, 2017, 7:23pm UTC](https://discuss.elastic.co/t/wildcard-not-working-as-expected/70489/3 "2017-01-04T19:23:02Z")

</div>

@dadoonet I just tried removing the space after the field name and get the same result. The query executes with no errors, I just don't get any results and I know there are in fact matching documents. I also tried using lowercase even though our data is normalized to all uppercase before we push it into Elastic and that did not work either. Does this have something to do with the fact that the field is NOT\_ANALYZED? Any addtional thoughts you may have on this would be appreciated. Thanks.

Kevin

---

<div class="post-metadata">

**Author:** ![krmathieu](https://avatars.discourse-cdn.com/v4/letter/k/b5e925/32.png) [@krmathieu](https://discuss.elastic.co/u/krmathieu)\
**Post date:** [January 4, 2017, 7:28pm UTC](https://discuss.elastic.co/t/wildcard-not-working-as-expected/70489/4 "2017-01-04T19:28:54Z")

</div>

This issue is resolved and this query works, note the wildcard piece of the query:

```
{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "wildcard": {"orgs.normalized": "UBE*"}
    }
}
```

This also works:

```
{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "query_string" : {
            "query" : "orgs.normalized: UBE*",
            "lowercase_expanded_terms": false
        }
    }
}
```

An excellent write-up of this issue can be found here:

> <https://github.com/elastic/elasticsearch/issues/9973>

Kevin

---

<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:** [February 1, 2017, 7:29pm UTC](https://discuss.elastic.co/t/wildcard-not-working-as-expected/70489/5 "2017-02-01T19:29:16Z")

</div>

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