I'm having some difficulties getting term filters to work properly. I poked around the mailing lists, and from what I can see, I'm doing the right thing, but it isn't working.
What I want to do is filter a query where a field exactly matches a string.
I have a mapping (bits elided):
{
"geojson": {
"properties": {
"properties": {
"type": "object",
"dynamic": "true",
"properties": {
"categories": {
"type": "string",
"index": "not_analyzed"}}}}}}
And I have a document, also with bits elided:
{'properties': {'categories': ['Food & Beverage', 'Restaurants', 'Mexican']}}}
My query looks like this:
{"query": {"filtered": {"filter": {"term": {"properties.categories": "Mexican"}}, "query": {"match_all": {}}}}}
This matches nothing. If I lower-case "Mexican," it matches my document. If I change the term filter to "Food & Beverage", it also matches nothing, and changing the case as with the single-word filter also matches nothing.
As I understand from reading the docs & ML:
- Term query/filter shouldn't analyze the searched/filtered value[1].
- Fields with index not_analyzed are stored unchanged[2].
But this doesn't seem to be the case. Perhaps also of interest, when I fetch my mapping from ES, I get this:
"categories" : {
"type" : "string"
}
No mention of index being analyzed or not_analyzed. Even though the examples have it set up the same way I have, maybe that isn't working? I'm using ElasticSearch 0.17.1
[1]: http://elasticsearch-users.115913.n3.nabble.com/Beginners-Query-Questions-tp2413095p2413372.html & http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html
[2]: http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html