# Wildcards search in exact phrase in query\_string search

**URL:** <https://discuss.elastic.co/t/wildcards-search-in-exact-phrase-in-query-string-search/13883>\
**Category:** Elasticsearch\
**Created:** [October 9, 2013, 6:47am UTC](https://discuss.elastic.co/t/wildcards-search-in-exact-phrase-in-query-string-search/13883 "2013-10-09T06:47:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_Jain](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Ankit\_Jain](https://discuss.elastic.co/u/Ankit_Jain)\
**Post date:** [October 9, 2013, 6:47am UTC](https://discuss.elastic.co/t/wildcards-search-in-exact-phrase-in-query-string-search/13883/1 "2013-10-09T06:47:35Z")

</div>

Hi All,

We would want to include a wildcards in a query\_string query when looking  
for a phrase.  
When we search with following query:  
{  
"query":{  
"query\_string":{  
"default\_operator" : "AND"  
"analyze\_wildcard": true,  
"default\_field":"value",  
"query":""great match""  
}  
}  
\*Output: \*4 records (returning all 4 records which contain "great match" in  
phrase.)

But, when I search with below query:  
{  
"query":{  
"query\_string":{  
"default\_operator" : "AND"  
"analyze\_wildcard": true,  
"default\_field":"value",  
"query":""great ma\*""  
}  
}

_Output:_ 10 records (returning all records which has either great or match  
with ma\* or both.)

is it possible to include a wildcards in a query\_string query when looking  
for a phrase?

Regards,  
Ankit Jain

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![shadyabhi](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@shadyabhi](https://discuss.elastic.co/u/shadyabhi)\
**Post date:** [October 13, 2013, 5:28pm UTC](https://discuss.elastic.co/t/wildcards-search-in-exact-phrase-in-query-string-search/13883/2 "2013-10-13T17:28:48Z")

</div>

Hi Ankit,

Using of quotes in your "query" part is avoiding "\*" from being  
interpreted. To do what you want, have a look at a previous post:  
[http://elasticsearch-users.115913.n3.nabble.com/Wildcards-in-exact-phrase-in-query-string-search-td4020826.html](http://elasticsearch-users.115913.n3.nabble.com/Wildcards-in-exact-phrase-in-query-string-search-td4020826.html)

On Wed, Oct 9, 2013 at 12:17 PM, Ankit Jain [ankitjaincs06@gmail.com](mailto:ankitjaincs06@gmail.com) wrote:

> Hi All,
> 
> We would want to include a wildcards in a query\_string query when looking  
> for a phrase.  
> When we search with following query:  
> {  
> "query":{  
> "query\_string":{  
> "default\_operator" : "AND"  
> "analyze\_wildcard": true,  
> "default\_field":"value",  
> "query":""great match""  
> }  
> }  
> Output: 4 records (returning all 4 records which contain "great match" in  
> phrase.)
> 
> But, when I search with below query:  
> {  
> "query":{  
> "query\_string":{  
> "default\_operator" : "AND"  
> "analyze\_wildcard": true,  
> "default\_field":"value",  
> "query":""great ma\*""  
> }  
> }
> 
> Output: 10 records (returning all records which has either great or match  
> with ma\* or both.)
> 
> is it possible to include a wildcards in a query\_string query when looking  
> for a phrase?
> 
> Regards,  
> Ankit Jain
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Regards,  
Abhijeet Rastogi (shadyabhi)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ankit\_Jain](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Ankit\_Jain](https://discuss.elastic.co/u/Ankit_Jain)\
**Post date:** [October 14, 2013, 12:02pm UTC](https://discuss.elastic.co/t/wildcards-search-in-exact-phrase-in-query-string-search/13883/3 "2013-10-14T12:02:39Z")

</div>

Hi Abhijeet,

Thanks for the reply..

its an typo on query. We are using wildcard search (\*) without quotes.

Below is the correct queries we are firing.  
{  
"query":{  
"query\_string":{  
"default\_operator" : "AND"  
"analyze\_wildcard": true,  
"default\_field":"value",  
"query":great ma\*  
}  
}

Regards,  
Ankit

On Sunday, 13 October 2013 22:58:48 UTC+5:30, Abhijeet Rastogi wrote:

> Hi Ankit,
> 
> Using of quotes in your "query" part is avoiding "\*" from being  
> interpreted. To do what you want, have a look at a previous post:
> 
> [http://elasticsearch-users.115913.n3.nabble.com/Wildcards-in-exact-phrase-in-query-string-search-td4020826.html](http://elasticsearch-users.115913.n3.nabble.com/Wildcards-in-exact-phrase-in-query-string-search-td4020826.html)
> 
> On Wed, Oct 9, 2013 at 12:17 PM, Ankit Jain \<[ankitj...@gmail.com](mailto:ankitj...@gmail.com)\<javascript:\>\>  
> wrote:
> 
> > Hi All,
> > 
> > We would want to include a wildcards in a query\_string query when  
> > looking  
> > for a phrase.  
> > When we search with following query:  
> > {  
> > "query":{  
> > "query\_string":{  
> > "default\_operator" : "AND"  
> > "analyze\_wildcard": true,  
> > "default\_field":"value",  
> > "query":""great match""  
> > }  
> > }  
> > Output: 4 records (returning all 4 records which contain "great match"  
> > in  
> > phrase.)
> > 
> > But, when I search with below query:  
> > {  
> > "query":{  
> > "query\_string":{  
> > "default\_operator" : "AND"  
> > "analyze\_wildcard": true,  
> > "default\_field":"value",  
> > "query":""great ma\*""  
> > }  
> > }
> > 
> > Output: 10 records (returning all records which has either great or  
> > match  
> > with ma\* or both.)
> > 
> > is it possible to include a wildcards in a query\_string query when  
> > looking  
> > for a phrase?
> > 
> > Regards,  
> > Ankit Jain
> > 
> > --  
> > You received this message because you are subscribed to the Google  
> > Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send  
> > an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Regards,  
> Abhijeet Rastogi (shadyabhi)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:12am UTC](https://discuss.elastic.co/t/wildcards-search-in-exact-phrase-in-query-string-search/13883/4 "2017-07-06T02:12:35Z")

</div>


