We are using function_score query to sort search results. The score takes into account the value of a field in the indexed document. However, it appears the field value can not be properly retrieved from Doc Values, it always returns '0' although the actual value is otherwise.
Here I prepared some documents and query to illustrate the problem, you may try it out in CONSOLE.
As the example shows the field 'reward_factor' in the indexed document is populated with non zero value, however, when it's retrieved using doc['reward_factor'].value, it is alway '0'. Tried other ways to retrieve the value, such as _fields (as documented here), no success.
One thing maybe special here is that the function_score query is under a 'nested' query, in such case, are we not able to retrieve the field value? No documentation seems indicating so.
Thank you Xavier for your answer. It makes sense although I do wish there is a way to get the field value from parent docs. I guess I have a walk-around that is to include 'reward_factor' field in each of the nested subdocuments. Not very elegant, but it should work.
Cheers,
Junjun
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.