Hi all. I've been trying to get a terms facet working along side not_analyzed fields an I'm at a bit of a loss about how to get some of this worked out.
First, I'm using a dynamic template, that allows for multi_field and where the fields have an analyzed section and an not_analyzed section. You can see and try the mapping here: https://gist.github.com/mkommar/9624564 I put in some test data: https://gist.github.com/mkommar/9624626 Now I try searching against the analyzed field (field1) and it works as I would think: curl -XGET localhost:9200/mtest/dynamics/_search?q=field1:Words {"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0}, "hits":{"total":1,"max_score":0.19178301,"hits":[{"_index":"mtest","_type": "dynamics","_id":"1","_score":0.19178301, "_source" : {"field1" : "Words are nice", "field2": "We are here"}}]}} I try searching field1 again with a different term that appears twice and it works as I would expect curl -XGET localhost:9200/mtest/dynamics/_search?q=field1:Word {"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0}, "hits":{"total":2,"max_score":0.30685282,"hits":[{"_index":"mtest","_type": "dynamics","_id":"3","_score":0.30685282, "_source" : {"field1" : "Word", "field2": "not a match"}},"_index":"mtest","_type":"dynamics","_id":"4", "_score":0.30685282, "_source" : {"field1" : "Word", "field2": "match"}}]}} If I search for the single word with the not_analyzed field, I get no matches. Something I don't expect. No hits: curl -XGET localhost:9200/mtest/dynamics/_search?q=field1.org:Word {"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0}, "hits":{"total":0,"max_score":null,"hits":[]}} However, if I search on whole phrases, I get a hit: curl -XGET localhost:9200/mtest/dynamics/_search?q=field1.org:Words%20are% 20nice {"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0}, "hits":{"total":1,"max_score":0.02250402,"hits":[{"_index":"mtest","_type": "dynamics","_id":"1","_score":0.02250402, "_source" : {"field1" : "Words are nice", "field2": "We are here"}}]}} So Question 1 is: How do I get hits on single words for not_analyzed fields? Question 2 is about the terms facet relating to this mapping / not_analyed setting. If I do a match_all against all the items and run a terms facet, I get the tokenized results I expect: curl -XGET localhost:9200/mtest/dynamics/_search -d '{ "query" : { "match_all": {} }, "facets" : { "topFieldElements" : { "terms" : { "field" : "field1", "size" : 10 } } } }' ... "facets":{"topFieldElements":{"_type":"terms","missing":0,"total":5, "other":0,"terms":[{"term":"word","count":2},{"term":"words","count":1},{ "term":"sentence","count":1},{"term":"nice","count":1}]}}} However, running the terms facet on not_analyzed fields results in no information (missing: 4): curl -XGET localhost:9200/mtest/dynamics/_search -d '{ "query" : { "match_all": {} }, "facets" : { "topFieldElements" : { "terms" : { "field" : "field1.org", "size" : 10 } } } }' {"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0}, "hits":{"total":4,"max_score":1.0,"hits":[{"_index":"mtest","_type": "dynamics","_id":"3","_score":1.0, "_source" : {"field1" : "Word", "field2": "not a match"}},{"_index":"mtest","_type":"dynamics","_id":"2","_score":1.0, "_source" : {"field1" : "this is a sentence", "field2": "We are here"}},{ "_index":"mtest","_type":"dynamics","_id":"4","_score":1.0, "_source" : { "field1" : "Word", "field2": "match"}},{"_index":"mtest","_type":"dynamics", "_id":"1","_score":1.0, "_source" : {"field1" : "Words are nice", "field2": "We are here"}}]},"facets":{"topFieldElements":{"_type":"terms","missing":4, "total":0,"other":0,"terms":[]}}} This appears to be the case in any amount of data (?). How can I get terms data in not_analyzed fields? Thanks! -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bf270a25-60d8-4f03-b2ed-d2dc568748b2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
