You need to use nested mapping in this case for item. Explained here:
Elasticsearch Platform — Find real-time answers at scale | Elastic,
When faceting, you can facet on nested objects, check here:
Elasticsearch Platform — Find real-time answers at scale | Elastic at the
bottom.
On Mon, Sep 12, 2011 at 12:59 PM, Andy selforganized@gmail.com wrote:
I have a product "Cotton Dress" and 2 items for that product:
{"size" : "S", "color" : "black"}, {"size" : "M", "color" : "blue"}
- How do I represent them as a JSON that I can index, is it something
like:{
"dress" {
"ProductName" : "Cotton Dress",
"_id" : 1234567
"Item" : [
{
"size" : "S",
"color" : "black"
},
{
"size" : "M",
"color" : "blue"
}
]
}
}And what is the mapping for "dress"? I read the doc and is still not
sure.
- How does faceting work with a nested document like this? Say I'm
faceting on "size" and "color",
- the above document should contribute the values "S", "M" for the
field "size", and the values "black", "blue" for the field "color"- if a user set a filter on "size" to "S", then the above document
should only contribute the value "black" (but not "blue") for the
field "color"
Is the above true? Or did I misunderstand how nested faceting work?