Facet_filter simple example does not work

Hi All,

I'm trying to execute statistical facet with filter. So I'm using
"facet_filter" without success.
Could you please help me with correct query?
Or maybe there is something else wrong?

My ElasticSearch version is 0.20.2.

My document structure/mapping is:
{"wch1":{"properties":{"HouseCode":{"type":"string",
"index":"not_analyzed"},"numbers":{"type":"long"},"period":{"type":"string",
"index":"not_analyzed"}}}}

Example document:
{HouseCode:"AB", period:["2013-04-03|2013-04-24", "2013-05-03|2013-05-24",
"2013-06-03|2013-06-24"], numbers:[3,13,7,33,179,170987]}

My query/facet is:
curl -XGET http://localhost:9200/test_wch/wch1/_search -d '{"facets" : {
"fname" : {"statistical" : {"field":"numbers"} }, "facet_filter" : {"term"
: { "HouseCode" : "AB"}} } } }'

And I get error:
... Parse Failure [No facet type found for [term]]]; }]","status":500}

Please help. Thanks in advance.

Best Regards,
Waldek

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

The facet_filter block needs to be under the fname facet declaration
(adjacent to the 'statistical' type)

{
"facets": {
"fname": {
"statistical": {
"field": "numbers"
},
"facet_filter": {
"term": {
"HouseCode": "ab"
}
}
}
}
}
}'

--
Ivan

On Fri, Mar 22, 2013 at 7:17 AM, waldemar@pureholidayhomes.com wrote:

Hi All,

I'm trying to execute statistical facet with filter. So I'm using
"facet_filter" without success.
Could you please help me with correct query?
Or maybe there is something else wrong?

My Elasticsearch version is 0.20.2.

My document structure/mapping is:
{"wch1":{"properties":{"HouseCode":{"type":"string",
"index":"not_analyzed"},"numbers":{"type":"long"},"period":{"type":"string",
"index":"not_analyzed"}}}}

Example document:
{HouseCode:"AB", period:["2013-04-03|2013-04-24", "2013-05-03|2013-05-24",
"2013-06-03|2013-06-24"], numbers:[3,13,7,33,179,170987]}

My query/facet is:
curl -XGET http://localhost:9200/test_wch/wch1/_search -d '{"facets" : {
"fname" : {"statistical" : {"field":"numbers"} }, "facet_filter" : {"term"
: { "HouseCode" : "AB"}} } } }'

And I get error:
... Parse Failure [No facet type found for [term]]]; }]","status":500}

Please help. Thanks in advance.

Best Regards,
Waldek

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

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

Thanks Ivan for your reply.

It helped, but now I have other problem, the statistic is taken from all
documents, not from that which have HouseCode = AB.
How should I filter a statistical facet for specyfic HouseCode or other
fields conditions?

Best Regards,
Waldek

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

A term filter/query does an exact match, so the term filtered on must have
the correct case. Not sure how I ended up lowercasing AB since all I did
was copy-n-paste.

--
Ivan

On Fri, Mar 22, 2013 at 9:04 AM, waldemar@pureholidayhomes.com wrote:

Thanks Ivan for your reply.

It helped, but now I have other problem, the statistic is taken from all
documents, not from that which have HouseCode = AB.
How should I filter a statistical facet for specyfic HouseCode or other
fields conditions?

Best Regards,
Waldek

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

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

I think it's not the lowercase/uppercase problem if the codes are exact.
I want to compute facet only on specific (filtered) documents and I'm not
able to do that with filter. I can only do that with query, which I don't
wont.
So is it possible to filter facet ? To do facet on filtered documents?

On Friday, 22 March 2013 17:08:50 UTC+1, Ivan Brusic wrote:

A term filter/query does an exact match, so the term filtered on must have
the correct case. Not sure how I ended up lowercasing AB since all I did
was copy-n-paste.

--
Ivan

On Fri, Mar 22, 2013 at 9:04 AM, <wald...@pureholidayhomes.com<javascript:>

wrote:

Thanks Ivan for your reply.

It helped, but now I have other problem, the statistic is taken from all
documents, not from that which have HouseCode = AB.
How should I filter a statistical facet for specyfic HouseCode or other
fields conditions?

Best Regards,
Waldek

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

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

After a very careful examination of the output.
It turns out that everything is fine.
Construction for the queries where, the query is by default "match_all" ES
shows / returns all documents, but the facet is calculated according to the
filter. (So be warned.)
It turns out that facet_filter works correctly.

Best for all,
and Ivan thanks for your help.

Greets,
Waldek

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