I have Elasticsearch cluster with e-shop data. There are many product in
there and they have attributes which belong to attribute categories. When I
search I don't know which attribute category are going to be returned and I
need facet statistic for every one of them.
E.g. documents look like:
{
"doc": "doc1",
categories: { "f1": "a", "f2": 0, "f3": "b", }
},
{
"doc": "doc2",
categories: { "f2": 3, "f3": "c", "f4": "d", }
}
I need to get facets statistic for every key in categories part of document
e.g. statistic for f1, f2, f3 etc. and I need to get it in one query (not
to get all categories first and then issue second query for actual
data)...It is ok if I have to change data structure. Is it possible to
do this using facets or aggregations in Elasticsearch?
I have Elasticsearch cluster with e-shop data. There are many product in
there and they have attributes which belong to attribute categories. When I
search I don't know which attribute category are going to be returned and I
need facet statistic for every one of them.
E.g. documents look like:
{
"doc": "doc1",
categories: { "f1": "a", "f2": 0, "f3": "b", }
},
{
"doc": "doc2",
categories: { "f2": 3, "f3": "c", "f4": "d", }
}
I need to get facets statistic for every key in categories part of
document e.g. statistic for f1, f2, f3 etc. and I need to get it in one
query (not to get all categories first and then issue second query for
actual data)...It is ok if I have to change data structure. Is it possible
to do this using facets or aggregations in Elasticsearch?
On Thu, Aug 28, 2014 at 2:51 PM, Krešimir Slugan <kresimi...@gmail.com
<javascript:>> wrote:
I have Elasticsearch cluster with e-shop data. There are many product in
there and they have attributes which belong to attribute categories. When I
search I don't know which attribute category are going to be returned and I
need facet statistic for every one of them.
E.g. documents look like:
{
"doc": "doc1",
categories: { "f1": "a", "f2": 0, "f3": "b", }
},
{
"doc": "doc2",
categories: { "f2": 3, "f3": "c", "f4": "d", }
}
I need to get facets statistic for every key in categories part of
document e.g. statistic for f1, f2, f3 etc. and I need to get it in one
query (not to get all categories first and then issue second query for
actual data)...It is ok if I have to change data structure. Is it possible
to do this using facets or aggregations in Elasticsearch?
It is nested query with bucketing by categories.key and then aggregating
by categories.value. For this to work, categories field has to have "type":
"nested" in mapping.json:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.