# Match all words - not necessarily in the same order

**URL:** <https://discuss.elastic.co/t/match-all-words-not-necessarily-in-the-same-order/22352>\
**Category:** Elasticsearch\
**Created:** [February 24, 2015, 11:09am UTC](https://discuss.elastic.co/t/match-all-words-not-necessarily-in-the-same-order/22352 "2015-02-24T11:09:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Rosko](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@Christophe\_Rosko](https://discuss.elastic.co/u/Christophe_Rosko)\
**Post date:** [February 24, 2015, 11:09am UTC](https://discuss.elastic.co/t/match-all-words-not-necessarily-in-the-same-order/22352/1 "2015-02-24T11:09:14Z")

</div>

Hi !

I'd like to make ES to find only docs matching all query words, but  
not necessarily in the same order, so match\_phrase is not what i'm looking  
for.  
Is there a query option doing that, or should i use minimum\_should\_match to  
100% ?

Thanks for your help

--  
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/77778c9d-8b82-44a0-9931-ced02666a185%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/77778c9d-8b82-44a0-9931-ced02666a185%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![David\_Klotz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_klotz/32/855_2.png) [@David\_Klotz](https://discuss.elastic.co/u/David_Klotz)\
**Post date:** [February 24, 2015, 2:52pm UTC](https://discuss.elastic.co/t/match-all-words-not-necessarily-in-the-same-order/22352/2 "2015-02-24T14:52:58Z")

</div>

Hi,

I think a simple match query with operator AND should do what you want!

Cheers,  
David

On Tuesday, February 24, 2015 at 12:09:14 PM UTC+1, Christophe Rosko wrote:

> Hi !
> 
> I'd like to make ES to find only docs matching all query words, but  
> not necessarily in the same order, so match\_phrase is not what i'm looking  
> for.  
> Is there a query option doing that, or should i use minimum\_should\_match  
> to 100% ?
> 
> Thanks for your help

--  
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/137574b1-034b-45ee-bf88-8073f3c0efec%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/137574b1-034b-45ee-bf88-8073f3c0efec%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Christophe\_Rosko](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@Christophe\_Rosko](https://discuss.elastic.co/u/Christophe_Rosko)\
**Post date:** [February 24, 2015, 2:59pm UTC](https://discuss.elastic.co/t/match-all-words-not-necessarily-in-the-same-order/22352/3 "2015-02-24T14:59:28Z")

</div>

Hi David,

I finally got what I wanted with this query :  
$es\_query = array(  
'match' =\> array(  
'\_all' =\> array(  
'query' =\> 'word1 word2 word3',  
'minimum\_should\_match' =\> '100%'  
)  
)  
);

But maybe this not the best way to do it.  
How do you do that with AND operator ? I didn't find an example in the  
documentation.

Thanks for your help, maybe my problem is stupid but i'm very new to ES.

Le mardi 24 février 2015 12:09:14 UTC+1, Christophe Rosko a écrit :

> Hi !
> 
> I'd like to make ES to find only docs matching all query words, but  
> not necessarily in the same order, so match\_phrase is not what i'm looking  
> for.  
> Is there a query option doing that, or should i use minimum\_should\_match  
> to 100% ?
> 
> Thanks for your help

--  
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/5b456423-7120-4840-aab5-d9a14625adc4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5b456423-7120-4840-aab5-d9a14625adc4%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, 12:30am UTC](https://discuss.elastic.co/t/match-all-words-not-necessarily-in-the-same-order/22352/4 "2017-07-06T00:30:30Z")

</div>


