Hello everybody
I'm working on a facet navigation and I've encountered an issue.
Let me explain what I'm trying to achieve first. Take a look at
http://www.pricerunner.co.uk/cl/2/TVs (not my site, just a basic example).
When you chose one filter, then it's applied to all facets but that
particular one (it's logical, because TVs cant be 30'' and 32'' at the same
time). That's simply achieved, but the problem arises when we want to add a
facet that is based on a field in a nested structure.
Let's say we've got a structure (mapping) like this:
curl -XPUT 'localhost:9200/items' -d '
{
"mappings" : {
"Item" : {
"dynamic" : false,
"properties" : {
"id" : { "type" : "string", "index" : "not_analyzed" },
"name" : { "type" : "string", "index" : "not_analyzed" },
"price" : { "type" : "double", "index" : "not_analyzed" },
"type" : { "type" : "string", "index" : "not_analyzed" },
"characteristics" : {
"type" : "nested",
"properties" : {
"name" : { "type" : "string", "index" : "not_analyzed" },
"value" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}
}
}
'
We want facets for the fields in the parent object - that's easy - and a
facet for characteristics (name -> value) - and thats troublesome.
So having the above mapping, my app would generate a query like this (let's
assume that some restrictions are already made):
curl -X POST 'localhost:9200/items/_search?pretty=true' -d '
{
"query" : {
"match_all" : {}
},
"facets" : {
"screen size" : {
"nested" : "characteristics",
"terms" : { "field" : "characteristics.value" },
"facet_filter" : {
"and" : [
{ "term" : { "characteristics.name" : "screen size" } }
]
}
},
"price" : {
"terms" : { "field" : "price" },
"facet_filter" : {
"and" : [
{ "term" : { "type" : "TV" } },
{ "term" : { "name" : "Shark largedisplay" } }
]
}
},
"type" : {
"terms" : { "field" : "type" },
"facet_filter" : {
"and" : [
{ "term" : { "name" : "Shark largedisplay" } }
]
}
},
"name" : {
"terms" : { "field" : "name" },
"facet_filter" : {
"and" : [
{ "term" : { "type" : "TV" } }
]
}
}
}
}
'
As you can see, I am able to provide some restrictions for regular facets.
Filter for the facet includes only conditions that are NOT related to the
field the facet is based on. But I'm not able to do this for the nested
facet, because I can't target fields of the parent objects from there.
I am curious about the 'proper' approach - this in my opinion should be a
common usage for the facets.
I would appriciate any given help.
Thanks in advance.
Paweł
--
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.
For more options, visit https://groups.google.com/groups/opt_out.