sudo-suhas/elastic-builder

Unable to create use score script inside the function score query

thechiragarora opened this issue · 2 comments

I have a query -

"function_score": { "query": { "term": { "test": { "value": "test" } } }, "script_score": { "script": { "source": "5" } }, "boost_mode": "replace" }

but while converting this to elastic builder I don't find any way to add script_score inside the function_score query -

This is what I have done, but it doesn't have script function -

esb.functionScoreQuery().query(esb.termQuery('test', test)) .boostMode('replace')

I checked ScriptScoreFunction but there also I don't find any way to add query, I am just able to add script but not query in it.

Thanks in advance.

I have similar problem i cannot find way to add something like this
{ "script_score":{ "query":{ "match":{ "name.raw":{ "query":"player" } } }, "script":{ "source":"doc['final_score'].value * 10" } } }
Maybe the best solution for this specific use cases would be to make some rawQuery builder ?!

I got the way -

esb.functionScoreQuery().query(query) .function(esb.scriptScoreFunction(esb.script('inline', score) .lang('painless'))) .boostMode('replace')