nest - elasticsearch scoring unique terms vs ngram terms -


i've figured out how return results on partial word result using ngrams. i'd arrange (score or sort) results based on term first , partial term.

for example, user searches movie db 'we'. want 'we marshall' , similar show @ top, , not 'north northwest'. (the 'we' in 'northwest').

currently mapping title field:

"title": {   "type": "string",   "analyzer": "ngramanalyer",   "fields": {      "term": {         "type": "string",         "analyzer": "fulltermcaseinsensitive"      },      "raw": {         "type": "string",         "index": "not_analyzed"      }   } } 

i've created multifield ngramanalyzer custom ngram, term using keyword tokenizer standard filter, , raw not_indexed.

my query follows:

"query": { "function_score": {   "functions": [     {       "script_score": {         "script": "_score * (1+ (1 / doc['salesrank'].value) )"       }     }   ],   "query": {     "bool": {       "must": [         {           "match_phrase": {             "title": {              "query": "we",               "max_expansions": 10             }           }         }       ],        "should":{         "term" : {            "title.term" : {              "value" : "we",              "boost" : 10              }         }       }     }   } } 

i'm requiring ngram must matched, , term 'we' should matched, , if so, boost it.

this isn't working of course.

any ideas?

edit

to add further complexity ... how match first on exact title, on custom score?

i've taken stabs @ it, doesn't seem work.

for example:

input: 'game' results should ordered exact match 'game'  followed custom score based on sales rank (integer) next results after 'game' might 'hunger games' 

what bool combination of boosting query, first match full term 10x boost factor, , matches against ngram term standard boost factor?


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -