Nested documents & faceting

I have a product "Cotton Dress" and 2 items for that product:
{"size" : "S", "color" : "black"}, {"size" : "M", "color" : "blue"}

  1. 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.

  1. 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?

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"}

  1. 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.

  1. 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?

Hi, Shay.

Could you show here example of nested faceting for Item? (assuming that it
is declared as nested)

Is it possible to facet on all fields of Item without directly indicating
it? Smth like
{"facets": {
"item_options":
{
"terms": {"field": "Item"},
"nested": "Item"
}
}

I'm still lurking solution for faceting on dynamic attributes.

понедельник, 12 сентября 2011 г., 21:59:21 UTC+6 пользователь kimchy
написал:

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 <...> wrote:

I have a product "Cotton Dress" and 2 items for that product:
{"size" : "S", "color" : "black"}, {"size" : "M", "color" : "blue"}

  1. 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.

  1. 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?