# Phrase wildcard search

**URL:** <https://discuss.elastic.co/t/phrase-wildcard-search/19693>\
**Category:** Elasticsearch\
**Created:** [September 9, 2014, 6:02pm UTC](https://discuss.elastic.co/t/phrase-wildcard-search/19693 "2014-09-09T18:02:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asthanaamish](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@asthanaamish](https://discuss.elastic.co/u/asthanaamish)\
**Post date:** [September 9, 2014, 6:02pm UTC](https://discuss.elastic.co/t/phrase-wildcard-search/19693/1 "2014-09-09T18:02:27Z")

</div>

We have a requirement to phrase wildcard search in elastic search.  
The requirement is to search for lets say search for "Barce\* Me\*i" and it  
should give any document which has "Barcelona Messi" in a phrase in ANY  
field.  
We have been able to do it using span near with slop 0, and it works fine .  
The issue is that it works only on a particular field of the document.  
The question is how can we make it work for any field in the document?

We tried to create a SPAN near query for each field and then encompass the  
whole in a boolean query but it does not work.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4093f991-fa00-4fb2-bcf6-8cdd9a59f884%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4093f991-fa00-4fb2-bcf6-8cdd9a59f884%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![asthanaamish](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@asthanaamish](https://discuss.elastic.co/u/asthanaamish)\
**Post date:** [September 9, 2014, 9:39pm UTC](https://discuss.elastic.co/t/phrase-wildcard-search/19693/2 "2014-09-09T21:39:16Z")

</div>

My quey is something like this :

"query":  
{  
"span\_near":  
{"clauses":  
[

{"span\_multi":{"match":{"wildcard":{"name":{"wildcard":"comp\*"}}}}}  
,{"span\_multi":{"match":{"wildcard":{"name":{"wildcard":"engaged"}}}}}  
]  
,"slop":0 ,"in\_order":true,"collect\_payloads":false  
}  
}

here I am searching for "comp\* engaged" as a phrase wildcard in name field.  
If I have multiple fields how do I do it? If I have to boost some field is  
there a way?

On Tuesday, September 9, 2014 11:02:27 AM UTC-7, Amish Asthana wrote:

> We have a requirement to phrase wildcard search in Elasticsearch.  
> The requirement is to search for lets say search for "Barce\* Me\*i" and it  
> should give any document which has "Barcelona Messi" in a phrase in ANY  
> field.  
> We have been able to do it using span near with slop 0, and it works fine .  
> The issue is that it works only on a particular field of the document.  
> The question is how can we make it work for any field in the document?
> 
> We tried to create a SPAN near query for each field and then encompass the  
> whole in a boolean query but it does not work.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b9a4acd5-a484-4e47-b036-576c36f789d7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9a4acd5-a484-4e47-b036-576c36f789d7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:03am UTC](https://discuss.elastic.co/t/phrase-wildcard-search/19693/3 "2017-07-06T01:03:33Z")

</div>


