Segregating search results by document type

I am working on a first elasticsearch project, where I am displaying a
search results page with hits segregated by type.

The types in this case are things like essays, journals, photos, reports,
etc., 9 total, though what they are is irrelevant. I currently store them
all in the same index; each type has its own mappings so I can support
special fields (e.g., photographer) in search results.

The main search results page displays 9 sections, segregated by type, with
up to N results in each.

I have this up and running, but only by running 9 searches in parallel to
get the top N hits in each type. Each query is of the form:
http://website:9200/index/type/_search…..

For the primary search page, I hate to run 9 elasticsearch queries when
somebody types in a query - is there a way to do this with a single query?
The problem with that, implemented naively anyway, is that I would like
the top N hits for each type even if they are not high scoring - in other
words, if the top 30 hits are essays I still would like to display the top
3 photos, and not 0 photos because none of them score high enough.

Rex Bradford

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/70a4517d-f493-4fe7-9be4-8b71af1855fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.