I ve been trying lately to upgrade my MyNativeScriptPlugin from ES 5.6.3 to an advanced script plugin in ES 7.4.0 using scriptEngine instead of NativeScriptFactory.
Until now I ve been succesfully building, deploying and running ES with my new plugin... except that it's not scoring my document.
I'm very new to ES so, maybe I'm missing something very obvious.
When I try a simple POST /_search
I can see 2 hits
But there is no hit when I try
POST /mytype/_search
{
"size":20,
"query": {
"function_score": {
"query": {
"match": {
"nom": "xxx"
}
},
"functions":[
{
"filter":{
"match_all":{
"boost":1.0
}
},
"script_score":{
"script":{
"source":"my-source",
"lang":"my-lang",
"params":{
"param1":"1111",
"param2":"2222"
}
}
}
}
]
}
}
}
I see that newInstance is called a few times.
But I'm never entering into the execute method.
This method is supposed to read from documents my fields values and return a custom score.
Getting the entrySet of the doc map won't work as we don't allow iterating over all docvalues fields of a doc. Instead, you need to lookup the particular field:
getDoc().get("myfield")
You'll then cast that to the appropriate ScriptDocValues subclass given your field type. However, the mapping examples above show only 2 text fields. Text fields are not stored in doc values. You'll need to add a keyword field if you want to access a string value, or use another field you have with numeric values.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.