# Multi\_match Vs match \_all

**URL:** <https://discuss.elastic.co/t/multi-match-vs-match--all/10548>\
**Category:** Elasticsearch\
**Created:** [January 29, 2013, 10:26pm UTC](https://discuss.elastic.co/t/multi-match-vs-match--all/10548 "2013-01-29T22:26:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giorgos\_Tsiftsis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giorgos_tsiftsis/32/2507_2.png) [@Giorgos\_Tsiftsis](https://discuss.elastic.co/u/Giorgos_Tsiftsis)\
**Post date:** [January 29, 2013, 10:26pm UTC](https://discuss.elastic.co/t/multi-match-vs-match--all/10548/1 "2013-01-29T22:26:25Z")

</div>

hi,  
If N fields (and only these) included in \_all field then a multi\_match  
query in N fields should be the same with a match query in \_all field (with  
the same options) ?  
In which situations the above could be false?  
thanks,  
g.

--  
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:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 30, 2013, 9:44am UTC](https://discuss.elastic.co/t/multi-match-vs-match--all/10548/2 "2013-01-30T09:44:40Z")

</div>

Yes, that is effectively the same. If you're using the `multi_match`  
query then you are more flexible, you can change fields you query by  
at any time. On top of this you can nicely play with different boosts  
per field when using the `multi_match` query.

On 29 January 2013 23:26, Giorgos Tsiftsis [giorgos.tsiftsis@gmail.com](mailto:giorgos.tsiftsis@gmail.com) wrote:

> hi,  
> If N fields (and only these) included in \_all field then a multi\_match  
> query in N fields should be the same with a match query in \_all field (with  
> the same options) ?  
> In which situations the above could be false?  
> thanks,  
> g.
> 
> --  
> 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).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [January 30, 2013, 10:09am UTC](https://discuss.elastic.co/t/multi-match-vs-match--all/10548/3 "2013-01-30T10:09:18Z")

</div>

On Wed, 2013-01-30 at 10:44 +0100, Martijn v Groningen wrote:

> Yes, that is effectively the same. If you're using the `multi_match`  
> query then you are more flexible, you can change fields you query by  
> at any time. On top of this you can nicely play with different boosts  
> per field when using the `multi_match` query.

Note also that the term frequencies and field length may be different in  
the \_all field and in the individual fields, which may affect scoring.

clint

--  
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:** ![Giorgos\_Tsiftsis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/giorgos_tsiftsis/32/2507_2.png) [@Giorgos\_Tsiftsis](https://discuss.elastic.co/u/Giorgos_Tsiftsis)\
**Post date:** [January 30, 2013, 11:23am UTC](https://discuss.elastic.co/t/multi-match-vs-match--all/10548/4 "2013-01-30T11:23:44Z")

</div>

What I don't understand is why I get different results with these 2 queries:  
Let \_all = field\_1, field\_2, field\_3

Query 1:  
multi\_match:  
{  
fields: ["\_all"],  
query: "a test query",  
operator: "and",  
analyzer: "my\_analyzer"  
}

Query 2:  
multi\_match:  
{  
fields["field\_1", "field\_2", field\_3"]  
query: "a test query",  
operator: "and",  
analyzer: "my\_analyzer"  
}

The behavior in Query 2 is different from Query 1, and as far as I  
understand the reason is that with Query 2 the results must have  
query in any of the fields provided but with no combinations (eg. "a" found  
in field\_1, "test" found in field\_2 etc). Is this correct?

(elasticsearch version 0.19.12)

On Wednesday, January 30, 2013 12:09:18 PM UTC+2, Clinton Gormley wrote:

> On Wed, 2013-01-30 at 10:44 +0100, Martijn v Groningen wrote:
> 
> > Yes, that is effectively the same. If you're using the `multi_match`  
> > query then you are more flexible, you can change fields you query by  
> > at any time. On top of this you can nicely play with different boosts  
> > per field when using the `multi_match` query.
> 
> Note also that the term frequencies and field length may be different in  
> the \_all field and in the individual fields, which may affect scoring.
> 
> clint

--  
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:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 30, 2013, 12:08pm UTC](https://discuss.elastic.co/t/multi-match-vs-match--all/10548/5 "2013-01-30T12:08:51Z")

</div>

Correct, in the case for query 2 for a document to have a hit, the  
document needs all the hits in either field\_1, field\_2 or field\_2. In  
the first query the combination of hits can span a cross those fields.  
In my initial response to your case I was assuming using the `or`  
operator (which is `or`)

Also do the `_all` field and the other fields have the same index time  
analyzer? This is must be the same if you want the same behaviour for  
both queries.

Martijn

On 30 January 2013 12:23, Giorgos Tsiftsis [giorgos.tsiftsis@gmail.com](mailto:giorgos.tsiftsis@gmail.com) wrote:

> What I don't understand is why I get different results with these 2 queries:  
> Let \_all = field\_1, field\_2, field\_3
> 
> Query 1:  
> multi\_match:  
> {  
> fields: ["\_all"],  
> query: "a test query",  
> operator: "and",  
> analyzer: "my\_analyzer"  
> }
> 
> Query 2:  
> multi\_match:  
> {  
> fields["field\_1", "field\_2", field\_3"]  
> query: "a test query",  
> operator: "and",  
> analyzer: "my\_analyzer"  
> }
> 
> The behavior in Query 2 is different from Query 1, and as far as I  
> understand the reason is that with Query 2 the results must have  
> query in any of the fields provided but with no combinations (eg. "a" found  
> in field\_1, "test" found in field\_2 etc). Is this correct?
> 
> (elasticsearch version 0.19.12)
> 
> On Wednesday, January 30, 2013 12:09:18 PM UTC+2, Clinton Gormley wrote:
> 
> > On Wed, 2013-01-30 at 10:44 +0100, Martijn v Groningen wrote:
> > 
> > > Yes, that is effectively the same. If you're using the `multi_match`  
> > > query then you are more flexible, you can change fields you query by  
> > > at any time. On top of this you can nicely play with different boosts  
> > > per field when using the `multi_match` query.
> > 
> > Note also that the term frequencies and field length may be different in  
> > the \_all field and in the individual fields, which may affect scoring.
> > 
> > clint
> 
> --  
> 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).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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:53am UTC](https://discuss.elastic.co/t/multi-match-vs-match--all/10548/6 "2017-07-06T02:53:56Z")

</div>


