# How can wildcard be used in a phrase query?

**URL:** <https://discuss.elastic.co/t/how-can-wildcard-be-used-in-a-phrase-query/104042>\
**Category:** Elasticsearch\
**Created:** [October 16, 2017, 1:51am UTC](https://discuss.elastic.co/t/how-can-wildcard-be-used-in-a-phrase-query/104042 "2017-10-16T01:51:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![esuser1027](https://avatars.discourse-cdn.com/v4/letter/e/ce7236/32.png) [@esuser1027](https://discuss.elastic.co/u/esuser1027)\
**Post date:** [October 16, 2017, 1:51am UTC](https://discuss.elastic.co/t/how-can-wildcard-be-used-in-a-phrase-query/104042/1 "2017-10-16T01:51:28Z")

</div>

What are the possible options for a phrase query to include wildcards using query\_string ?  
Without the wildcard below query returns some result. However, adding wildcard in any part of the query will no longer work.

I have seen similar questions on this but no working solution.

```
        {  
           "query_string":{  
              "query":"message:\"My Resume*\"",
              "default_field":"subject",
              "default_operator":"or",
              "auto_generate_phrase_queries":false,
              "allow_leading_wildcard":false,
              "enable_position_increment":true,
              "analyze_wildcard":true,
              "split_on_whitespace":true,
           }
        }

```

I was expecting following results to match for above query.  
My Resume 2017  
My Resume 2013  
My Resume

What are my other options?

---

<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:** [October 16, 2017, 5:20am UTC](https://discuss.elastic.co/t/how-can-wildcard-be-used-in-a-phrase-query/104042/2 "2017-10-16T05:20:02Z")

</div>

Without using any wildcard the phrase query will match the 3 documents by default. Why do you want to ask your user to add a wildcard ?

---

<div class="post-metadata">

**Author:** ![esuser1027](https://avatars.discourse-cdn.com/v4/letter/e/ce7236/32.png) [@esuser1027](https://discuss.elastic.co/u/esuser1027)\
**Post date:** [October 17, 2017, 4:15am UTC](https://discuss.elastic.co/t/how-can-wildcard-be-used-in-a-phrase-query/104042/3 "2017-10-17T04:15:10Z")

</div>

Thanks, David.

Ok, my example and query need to be updated. I have following data indexed in elasticsearch.

1. My Resume 2017
2. My Resume 2013
3. My Resume
4. My Old Resume
5. My Reservation
6. My Resolution
7. My New Year Resolution
8. My \_\_Resume with lot of spaces

The problem is the space. If user search for "My Res\*", it is expected to match 1,2,3,5,6. Because of the space in between, phrase query seems to be the ideal choice but it seems that \* is not interpreted as a wildcard. What are my options?

---

<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 14, 2017, 4:15am UTC](https://discuss.elastic.co/t/how-can-wildcard-be-used-in-a-phrase-query/104042/4 "2017-11-14T04:15:57Z")

</div>

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