How to retrieve values from nested json element while using function in query


(Deb) #1

I have a Query running against Elastic Search version 5.5.2 where I need to get a custom boost score for a particular document in the scored result so that it goes to the top of the search result based on a particular search term. I am using function and filter to achieve that where I am extracting data from indexed fields.

"functions": [
                {
                    "filter": {
                        "match": {
                            "**meta.keyword.value**": "Lorem" . <===- This works
                        }
                    },
                    "script_score": {
                        "script": {
                            "inline": "doc['**meta.weight_factor**'].value" . <====  This does not work.
                        }
                    }
                }
            ]

Indexed elements will come from this-

"meta": {
.....
"keyword": [
              "Lorem"
            ],
            "weight_factor": [
              "10"
            ] 

}

I tried to implement nested query to provide path for "meta", however that is not working since I cannot use nested query at the top level to support the original search query.

So is there any way to grab the "weight_factor" value inside the function and use that inside "script" ?


(system) #2

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