Access Object field type doc value in function score query


(Heeren Sharma) #1

Version ES:2.4
In document, I have field called "domain_score" which is an Object type. e.g.
{"field1": {"de": {"de": 2} } }
Default value of this field is {} i.e empty dictionary.
In my scoring script I am applying two parameters, language and country. My script looked something like this.

float boost = 0.0;
domain_score = doc["domain_score"].value ;
isCountry = doc["domain_score"].get(country) ;
if (isCountry != null) {
    isLanguage = doc["domain_score"][country].get(language)
    if (isLanguage != null) {
        val = doc["domain_score"][country][language]
        if (val > 0) {
            boost = val 
        }
    }
} ;
return boost ;

Its giving me the error that its not a correct groovy script.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.