Distinct queries across multiple types in one request?


(qjh) #1

Is it possible to issue distinct queries to multiple types within the
same index? I have a few types with different mappings (some overlap)
and I need to query some of the fields of each with the same query
string, but the queries are inherently different because of the
mappings. It seems like it is only possible to execute the same query
against multiple types. If that is the case, how would you guys feel
about extending the API to support multiple distinct queries?

Here is a gist with the current queries and below that is a rough idea
of how the multiple queries could work.


(Mark Waddle) #2

Could you search at the index level like your gist, but include the "_type"
field in each query, and combine the queries with an OR?


(qjh) #3

That is probably is fine query, but it would give me all the results
mixed and scored together. I need to them to be separated based on
the type in the results.

Thanks for the reply, though!


(qjh) #4

Anyone else have thoughts on this? Is there a way to accomplish it
presently? Does it seem like a reasonable API to implement?

Thanks!


(Shay Banon) #5

There is no way to get distinct results per type with different queries except if you execute several search requests per type.

On Wednesday, February 1, 2012 at 1:02 PM, qjh wrote:

Anyone else have thoughts on this? Is there a way to accomplish it
presently? Does it seem like a reasonable API to implement?

Thanks!


(qjh) #6

Thanks for the reply, Shay. Is that something you think is reasonable
to implement in ES as opposed to in the client? I would picture it
being similar to the bulk indexing/delete API but with queries, as
demonstrated in the gist I posted.


(Shay Banon) #7

Effectively what you are after is "multi search" API, its definitely possible, but not high on the list (at least for now…) since you can execute several search requests, and its less acute compared to multi get / batch indexing.

On Tuesday, January 24, 2012 at 2:01 AM, qjh wrote:

Is it possible to issue distinct queries to multiple types within the
same index? I have a few types with different mappings (some overlap)
and I need to query some of the fields of each with the same query
string, but the queries are inherently different because of the
mappings. It seems like it is only possible to execute the same query
against multiple types. If that is the case, how would you guys feel
about extending the API to support multiple distinct queries?

Here is a gist with the current queries and below that is a rough idea
of how the multiple queries could work.

https://gist.github.com/bcdeb73fb9b52b0f7564


(Roly Vicaria) #8

What would this kind of query look like?

On Monday, January 23, 2012 11:05:04 PM UTC-5, Mark Waddle wrote:

Could you search at the index level like your gist, but include the
"_type" field in each query, and combine the queries with an OR?


(system) #9