Facet_filters question

I'm having a difficult time getting facet_filters to work. I created a
gist
at: https://gist.github.com/1674000

If I understand correctly, I can use a "facet_filter" to limit the
scope of
my requested facet. So given a sample document:

{
"color": "blue",
"type": "crayon"
}

If I wanted to create a facet based on "color" but limit the results
to
only records of "type" == "crayon", then a "facet_filter" is the
correct
way to do this, or am I mistaken?

Thanks!
-jesse

Hi,

Using facet_filter you can do something like this :
{
facets : {
"colors" : {
"terms" : {
"field": "color"
},
"facet_filter": {
"term": { "type" : "crayon" }
}
}
}

But unless specific needs, (like multifaceting) you should use a
filtered query instead and move your filter inside its filter part :

{
query: {
filtered: {
query : ...
filter: {
"term": { "type" : "crayon" }
}
}
},
facets : {
"colors" : {
"terms" : {
"field": "color"
}
}
}

2012/1/25 jessejlt jessejlt@gmail.com:

I'm having a difficult time getting facet_filters to work. I created a
gist
at: gist:1674000 · GitHub

If I understand correctly, I can use a "facet_filter" to limit the
scope of
my requested facet. So given a sample document:

{
"color": "blue",
"type": "crayon"
}

If I wanted to create a facet based on "color" but limit the results
to
only records of "type" == "crayon", then a "facet_filter" is the
correct
way to do this, or am I mistaken?

Thanks!
-jesse

--
David Stendardi

I forgot to mention the error in your gist :
the facet_filter is at the same level that the facet name.
It should be inside your facet (same level as facet_type, as explained
here : Elasticsearch Platform — Find real-time answers at scale | Elastic)

2012/1/25 jessejlt jessejlt@gmail.com:

I'm having a difficult time getting facet_filters to work. I created a
gist
at: gist:1674000 · GitHub

If I understand correctly, I can use a "facet_filter" to limit the
scope of
my requested facet. So given a sample document:

{
"color": "blue",
"type": "crayon"
}

If I wanted to create a facet based on "color" but limit the results
to
only records of "type" == "crayon", then a "facet_filter" is the
correct
way to do this, or am I mistaken?

Thanks!
-jesse

--
David Stendardi