I know that elasticsearch takes the length of the field into account when calculating the score of documents received on request. The shorter the field, the higher the weight (see Field Length Norm ).
I like this behavior: when searching for iphone I am much more interested in iphone 6 than in Crappy accessories for: iphone 5 iphone 5s iphone 6 .
Now, I would like to try to increase this material, let's say that I want to double its value.
I know that you can change the score using the function score , and I assume that I can achieve what I want through the script score .
I tried to add another field length norm to the table:
{ "query": { "function_score": { "boost_mode": "replace", "query": {...}, "script_score": { "script": "_score + norm(doc)" } } } }
But I failed by getting this error: [No parser for element [function_score]]
EDIT:
My first mistake was that I did not complete the evaluation of the function in the "request". Now I edited the code above. My new mistake says
GroovyScriptExecutionException[MissingMethodException [No signature of method: Script5.norm() is applicable for argument types: (org.elasticsearch.search.lookup.DocLookup) values: [<org.elasticsearch.search.lookup.DocLookup@2c935f6f>] Possible solutions: notify(), wait(), run(), run(), dump(), any()]]
EDIT: I gave the first answer, but I hope for the best
elasticsearch boosting
Mario trucco
source share