Facted navigation with totals, drilling down

I have two 'types' in an index, or two indices of different types (I'd
prefer the latter but can live with the former).

I'm running an aggregation by type to implement what my UX people refer to
as faceted search — which makes Googling for ES help quite tricky.

UX would like to filter by type but retain a count for total hits in each
aggregation bucket — it the total number of each type of record that
matches the query.

Can this be done in one query?

Failing that, can two queries be supplied/run in parallel?

Thanks
Lee

--
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/8a815ff7-3fb0-480f-ab4a-0786577d4cb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello Lee ,

For multiple search queries in a single call , you can use _msearch -
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-multi-search.html

Thanks
Vineeth

On Sun, Sep 7, 2014 at 6:27 PM, Lee Gee leegee@gmail.com wrote:

I have two 'types' in an index, or two indices of different types (I'd
prefer the latter but can live with the former).

I'm running an aggregation by type to implement what my UX people refer to
as faceted search — which makes Googling for ES help quite tricky.

UX would like to filter by type but retain a count for total hits in each
aggregation bucket — it the total number of each type of record that
matches the query.

Can this be done in one query?

Failing that, can two queries be supplied/run in parallel?

Thanks
Lee

--
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/8a815ff7-3fb0-480f-ab4a-0786577d4cb6%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/8a815ff7-3fb0-480f-ab4a-0786577d4cb6%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CAGdPd5%3DY_XH7z%2Bx%3D1mx_O7OPhHJ56gn%3D3sqYndtMbgfe1XsUdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Not being too sure of the essence of your question let me fire some random
info at you :slight_smile:

  1. If you use a query (rather than filter) then the aggregation will
    reflect the totals for that query. ie the query is global.
  2. If you want to do an aggregation that is independent of that query, then
    you have to set its scope to 'global' - (I cant remember the exact syntax
    right now).
  3. If you want to apply another filter criteria, use a filter aggregation
    first, then your subaggregations below that (you can nest aggregations)

Sometimes with a faceted search, you want to show the totals of various
categories based on the search criteria that already exists. You sometimes
find you also want to show the categories for which there are zero
applicable documents (possibly because the chosen filter criteria are such
that they no longer match) - for that you need to do two aggregations - 1
to get the the totals - plus global one to get all the categories that have
count zero with the current criteria.

I hope that helps in some way....

On Sunday, 7 September 2014 13:57:40 UTC+1, Lee Gee wrote:

I have two 'types' in an index, or two indices of different types (I'd
prefer the latter but can live with the former).

I'm running an aggregation by type to implement what my UX people refer to
as faceted search — which makes Googling for ES help quite tricky.

UX would like to filter by type but retain a count for total hits in each
aggregation bucket — it the total number of each type of record that
matches the query.

Can this be done in one query?

Failing that, can two queries be supplied/run in parallel?

Thanks
Lee

--
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/97fab7ec-c2ef-42cd-8a82-6620d3ed8d4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello Lee ,

Post filter might be what you are looking for.
Post filters are only applied once aggregation is done -
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-post-filter.html#search-request-post-filter

Hence you can do the terms aggregation on _type field , and filter using
post filter.
It should fit your use case perfectly.

Thanks
Vineeth

On Sun, Sep 7, 2014 at 6:27 PM, Lee Gee leegee@gmail.com wrote:

I have two 'types' in an index, or two indices of different types (I'd
prefer the latter but can live with the former).

I'm running an aggregation by type to implement what my UX people refer to
as faceted search — which makes Googling for ES help quite tricky.

UX would like to filter by type but retain a count for total hits in each
aggregation bucket — it the total number of each type of record that
matches the query.

Can this be done in one query?

Failing that, can two queries be supplied/run in parallel?

Thanks
Lee

--
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/8a815ff7-3fb0-480f-ab4a-0786577d4cb6%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/8a815ff7-3fb0-480f-ab4a-0786577d4cb6%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CAGdPd5%3D%2B7EM%2BxBcSiLs_2EqjX%2BHBGiXZbRdAXMk%3DNh_oA151KA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Thank you, all.

On Sunday, September 7, 2014 1:57:40 PM UTC+1, Lee Gee wrote:

I have two 'types' in an index, or two indices of different types (I'd
prefer the latter but can live with the former).

I'm running an aggregation by type to implement what my UX people refer to
as faceted search — which makes Googling for ES help quite tricky.

UX would like to filter by type but retain a count for total hits in each
aggregation bucket — it the total number of each type of record that
matches the query.

Can this be done in one query?

Failing that, can two queries be supplied/run in parallel?

Thanks
Lee

--
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/77035121-06ac-436f-8165-9ab44bc1b47c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.