# Using \_msearch with suggesters only?

**URL:** <https://discuss.elastic.co/t/using--msearch-with-suggesters-only/18828>\
**Category:** Elasticsearch\
**Created:** [July 23, 2014, 2:36pm UTC](https://discuss.elastic.co/t/using--msearch-with-suggesters-only/18828 "2014-07-23T14:36:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordon\_Rankin](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Gordon\_Rankin](https://discuss.elastic.co/u/Gordon_Rankin)\
**Post date:** [July 23, 2014, 2:36pm UTC](https://discuss.elastic.co/t/using--msearch-with-suggesters-only/18828/1 "2014-07-23T14:36:52Z")

</div>

I have to query several completion suggesters at the same time. This is  
easy to do using the \_suggest api.

However if I want to query multiple suggesters on different indexes I have  
two choices:

1. Perform multiple http requests using the \_suggest api
2. Use the \_msearch api.

I am currently using option 1 which appears to perform reasonably well so  
far however I would like to only perform a single request if possible so I  
have been playing with the \_msearch api.

The problem is when performin a single \_msearch request for multiple  
suggesters on multiple indexes, each index also ends up getting queried,  
return all the hits as though I had also queried with matchall : {}

In order to minimize this issue I have set the size parameter to 0 which  
prevents the hits from being returned. However I still get a total count  
returned for all the documents in each index.

This implies to me that Elasticsearch is still doing some unnecessary work  
matching and counting documents in each index when all I really want  
returned are the suggestions.

- Is Elasticsearch actually performing any work other than for the  
suggesters?
- If so is there another way to return suggestion from multiple  
completion suggesters across several indices in a single request without  
querying at all?
- Would using \_msearch in this manner be considered a better practice  
than performing two or more \_suggest calls in parallel?

My request currently looks like this:

var request = [{  
index: 'users',  
type: 'user'  
},  
{  
size : 0,  
suggest: {  
users\_suggest: {  
text: term,  
completion: {  
size : 5,  
field: 'users\_suggest'  
}  
}  
}  
},  
{  
index: 'photos',  
type: 'photo'  
},  
{  
size : 0,  
suggest : {  
tags\_suggest: {  
text: term,  
completion: {  
size : 3,  
field: 'tags\_suggest'  
}  
},  
place\_suggest: {  
text: term,  
completion: {  
size : 3,  
field: 'place\_suggest'  
}  
},  
country\_suggest: {  
text: term,  
completion: {  
size : 3,  
field: 'country\_suggest'  
}  
}  
}  
}];

And the results I am getting returned are as follows :

[{  
"took": 8,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 28,  
"max\_score": 0,  
"hits": []  
},  
"suggest": {  
"users\_suggest": [{  
"text": "t",  
"offset": 0,  
"length": 1,  
"options": [**_suggestions_**]  
}]  
}  
}, {  
"took": 8,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 117,  
"max\_score": 0,  
"hits": []  
},  
"suggest": {  
"country\_suggest": [{  
"text": "t",  
"offset": 0,  
"length": 1,  
"options": []  
}],  
"place\_suggest": [**_suggestions_**]  
}],  
"tags\_suggest": [**_suggestions_**]  
}]  
}  
}]

--  
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/21f8e109-5741-4ba0-84de-1c41759dea6a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/21f8e109-5741-4ba0-84de-1c41759dea6a%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:13am UTC](https://discuss.elastic.co/t/using--msearch-with-suggesters-only/18828/2 "2017-07-06T01:13:54Z")

</div>


