elasticsearch - Elastic search exact match -


i'm using elasticsearch , having devil of time getting exact match happen. i've tried various combinations of match, query_string, etc, , either nothing or bad results. query looks this:

{   "filter": {     "term": {       "term": "dog",       "type": "main"     }   },   "query": {     "match_phrase": {       "term": "dog"     }   },   "sort": [     "_score"   ] } 

sorted results

10.102211 {u'term': u'the dog', u'type': u'main', u'conceptid': 7730506} 10.102211 {u'term': u'that dog', u'type': u'main', u'conceptid': 4345664} 10.102211 {u'term': u'dog', u'type': u'main', u'conceptid': 144} 7.147442 {u'term': u'dog eat dog (song)', u'type': u'main', u'conceptid': u'5288184'} 

i see, of course "the dog", "that dog" , "dog" have same score, need figure out how can boost exact match "dog" in score.

i tried

{   "sort": [     "_score"   ],   "query": {     "bool": {       "must": [         {           "match": {             "term": "dog"           }         },         {           "match_phrase": {             "term": {               "query": "dog",               "boost": 5             }           }         }       ]     }   },   "filter": {     "term": {       "term": "dog",       "type": "main"     }   } } 

but still gives me

11.887239 {u'term': u'the dog', u'type': u'main', u'conceptid': 7730506} 11.887239 {u'term': u'that dog', u'type': u'main', u'conceptid': 4345664} 11.887239 {u'term': u'dog', u'type': u'main', u'conceptid': 144} 8.410372 {u'term': u'dog eat dog (song)', u'type': u'main', u'conceptid': u'5288184'} 

fields analyzed standard analyzer default. if check exact match, store field not analyzed e.g:

"dog":{             "type":"multi_field",             "fields":{                 "dog":{                     "include_in_all":false,                     "type":"string",                     "index":"not_analyzed",                     "store":"no"                 },                 "_tokenized":{                     "include_in_all":false,                     "type":"string",                     "index":"analyzed",                     "store":"no"                 }             }         } 

then can query dog-field exact matches, , dog._tokenized analyzed queries (like fulltext)


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -