Query Filter on not_analyzed array field does not match whitespace/hyphen

(bashir) #1

I've been scratching my head for some time on this one. Major brownie points for any guidance:
I have mapping:
mapping :show => { :properties => {...
:tags => {:type => 'string', :index_name => 'tag', :boost => 80, :index => 'not_analyzed'},

tags is an array of tags. For example:
"tags":["rails","ruby on rails"]

I run a query as such(notice no results):

curl -X GET "http://localhost:9200/magic/_search?from=0&page=1&per_page=24&size=24pretty=true" -d '{"sort":[[{"score":"desc"}]],"filter":{"terms":{"tags":["ruby on rails"]}},"size":24,"from":0}'
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]

If I run it with "tags":["ruby"], it will match all documents that are tagged "ruby" and all documents tagged "ruby on rails". I don't want a substring search, I need an exact search and I thought if the field is "not_analyzed" that it would be an exact match. How to do this the right way. Notice that this is a filter and not query.

(system) #2