I have a indexed field e.g. called "text" now i want to replace the relevance score by using the "function_score" query.
Here is my query:
{
"index":"search-read",
"type":"all",
"body":{
"from":0,
"size":30,
"explain":true,
"query":{
"function_score":{
"query":{
"query_string":{
"query":"assetType:ARTICLE AND miete"
}
},
"script_score":{
"script":"doc['text'].value.length()"
},
"boost_mode":"replace"
}
}
}
}
The problem i do not understand is that
doc['text'].value.length()
do not retrieve me the length of a string, but why? A string with 2455 chars is stored in this field but i get 14.
This
doc['text'].value
should return me the field 'text' as java string object and than length() the length. Some ideas why my config is wrong or a other way to achive this? My goal is to lower the relevance score the shorter the text is; i know that this is the opposite how elasticsearch handles this.