# Multi\_match query and match \_all returns different set of results

**URL:** <https://discuss.elastic.co/t/multi-match-query-and-match--all-returns-different-set-of-results/21900>\
**Category:** Elasticsearch\
**Created:** [January 29, 2015, 1:28pm UTC](https://discuss.elastic.co/t/multi-match-query-and-match--all-returns-different-set-of-results/21900 "2015-01-29T13:28:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan\_Prokes](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@Jan\_Prokes](https://discuss.elastic.co/u/Jan_Prokes)\
**Post date:** [January 29, 2015, 1:28pm UTC](https://discuss.elastic.co/t/multi-match-query-and-match--all-returns-different-set-of-results/21900/1 "2015-01-29T13:28:04Z")

</div>

Hi there,

I need to search in multiple fields where I do not know field names in  
advance, so I can't use multi\_match syntax. So I found, that \_all field  
aggregates all fields set to be included in all in mapping. Unfortunately  
it returns different result set, that multi\_match. Here is complete test  
set for Sense.

What I'm doing wrong?

thank you for any response.

# Delete the `my_index` index

DELETE /my\_index

# Create `my_index` with a single primary shard

# and set up the `autocomplete` analyzer using

# edge ngrams

PUT /my\_index  
{  
"settings": {  
"number\_of\_shards": 1,  
"analysis": {  
"filter": {  
"autocomplete\_filter": {  
"type": "edge\_ngram",  
"min\_gram": 1,  
"max\_gram": 20  
}  
},  
"analyzer": {  
"autocomplete": {  
"type": "custom",  
"tokenizer": "standard",  
"filter": [  
"lowercase",  
"autocomplete\_filter"  
]  
}  
}  
}  
}  
}

# Map the `name` and `desc` field to use the `autocomplete` analyzer

PUT /my\_index/\_mapping/mytype  
{  
"mytype": {  
"properties": {  
"name": {  
"type": "string",  
"analyzer": "autocomplete"  
},  
"desc": {  
"type": "string",  
"analyzer": "autocomplete"  
}  
}  
}  
}

# Index some example docs

POST /my\_index/mytype/\_bulk  
{"index":{"\_id":1}}  
{"name":"Brown foxes","desc":"runs fast"}  
{"index":{"\_id":2}}  
{"name":"Yellow furballs","desc":"falls fast"}

# Use the "standard" analyzer on the query string

# instead of the "autocomplete" analyzer

GET /my\_index/mytype/\_search  
{  
"query": {  
"multi\_match": {  
"query": "brown fo",  
"analyzer": "standard",  
"fields": ["name", "desc"]  
}  
}  
}

GET /my\_index/mytype/\_search  
{  
"query": {  
"match": {  
"name": {  
"query": "brown fo",  
"analyzer": "standard"  
}  
}  
}  
}

# Update the mapping for the `name` field

# to use the "autocomplete" analyzer at index time

# and the "standard" analyzer at search time

PUT /my\_index/mytype/\_mapping  
{  
"mytype": {  
"properties": {  
"name": {  
"type": "string",  
"index\_analyzer": "autocomplete",  
"search\_analyzer": "standard",  
"include\_in\_all": true  
},  
"desc": {  
"type": "string",  
"index\_analyzer": "autocomplete",  
"search\_analyzer": "standard",  
"include\_in\_all": true  
}  
}  
}  
}

# Make sure that the mapping is ok

GET /my\_index/mytype/\_mapping

# Search in all fields via multi\_match - text in name field found and

result returned  
GET /my\_index/mytype/\_search  
{  
"query": {  
"multi\_match": {  
"query": "brown fo",  
"fields": ["name", "desc"]  
}  
}  
}

# Search in all fields via \_all field - text in name field found and result

returned  
GET /my\_index/mytype/\_search  
{  
"query": {  
"match": {  
"\_all": "brown fo"  
}  
}  
}

# Search in all fields via multi\_match - text in desc field found and

results (both) returned  
GET /my\_index/mytype/\_search  
{  
"query": {  
"multi\_match": {  
"query": "fa",  
"fields": ["name", "desc"]  
}  
}  
}

# Search in all fields via \_all field - text in desc field is, but no

result returned. multi\_match and match in \_all field does not return the  
same value. How to search in all fields, when I do not know field names?  
GET /my\_index/mytype/\_search  
{  
"query": {  
"match": {  
"\_all": "fa"  
}  
}  
}

--  
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/673cc9ce-1b6f-499f-b59a-cd7919e5cb07%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/673cc9ce-1b6f-499f-b59a-cd7919e5cb07%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:35am UTC](https://discuss.elastic.co/t/multi-match-query-and-match--all-returns-different-set-of-results/21900/2 "2017-07-06T00:35:57Z")

</div>


