node.js - Elasticsearch: Searching for fields with mapping not_analyzed get no hits -
i have elasticsearch running , requests nodejs. have following mapping applied index "mastert4":
{ "mappings": { "mastert4": { "properties": { "s": { "type": "string", "index": "not_analyzed" } } } } }
i added 1 document index looks pretty this:
{ "master": { "vi": "ff155d9696818dde0627e14c79ba5d344c3ef01d", "s": "anne will" } }
now doing of following search queries not return hits:
{ "index": "mastert4", "body": { "query": { "filtered": { "query": { "match"/"term": { "s": "anne will"/"anne will" } } } } }
}
but following query return exact document:
{ "index": "mastert4", "body": { "query": { "filtered": { "query": { "constant_score": { "filter": [ { "missing": { "field": "s" } } ] } } } } } }
and if search for
{ "exists": { "field": "s" } }
i no hits again.
when analyzing field itsself get:
{ "tokens": [ { "token": "anne will", "start_offset": 0, "end_offset": 9, "type": "word", "position": 1 } ] }
i'm in dead end here. can tell me did wrong? thx!!!!
you've enclosed fields s
, vi
inside outer field called master
not declared in mapping. that's reason. if query master.s
, you'll results.
the second solution remove enclosing master
object in document , work also:
{ "vi": "ff155d9696818dde0627e14c79ba5d344c3ef01d", "s": "anne will" }
Comments
Post a Comment