Fetching results from ES based on multiple queries

I've a scenario, where i need to get one value for each search term query,
For example:
"must": [

    { "match": { "name": "john" }},
    {"match": { "name": "smith" }}

this is an example query, where i need a resultset for each name matching "john"
and another matching "smith".

So, eventhough if there are more than one result set matches with "john" and "smith", need one result for eachh query.

I am using 1.1.2 version.

Hi @vasanth_kumar,

the msearch API seems like a good fit if I've understood your requirements correctly.

btw, there is no 1.9 version of Elasticsearch. Did you mean 0.9 or 1.7?


Thanks @danielmitterdorfer.
we are using, 1.1.2 version. This serves the need, but lets say my search criteria is dynamic, this solution would be little tricky:worried:

Hi @vasanth_kumar,

well, you then need to build the msearch JSON also dynamically. I don't know your client language but in general, you could use the GOF Builder pattern to build your msearch query dynamically.


Thanks @danielmitterdorfer. I'll try.