Before, I had this:
{
query: {
function_score: {
filter: {
and: [
{
term: {
'currency': 'usd',
'_cache': false
}
}
]
},
script_score: {
"script": "_score * doc['random_score'].value"
}
}
}
}
Very basic, I just filter by currency and sort by a score.
But every since I upgraded, I can't get any simple custom score query to work.
I've tried to simplify it with this example:
{
query: {
function_score: {
script_score: {
"script": "_score * doc['random_score'].value"
}
}
}
}
And I'm getting errors such as:
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[PxzZtO8FQviuhxS-3EJFwA][listings][3]:
SearchParseException[[listings][3]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"function_score": {
"script_score": {
"script": "_score * doc['random_score'].value"
}
}
}
}
]]];
nested: QueryParsingException[[listings] script_score the script could not be loaded];
nested: ScriptException[dynamic scripting for [mvel] disabled]; }{[PxzZtO8FQviuhxS-3EJFwA][listings][4]:
SearchParseException[[listings][4]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"function_score": {
"script_score": {
"script": "_score * doc['random_score'].value"
}
}
}
}
]]];
nested: QueryParsingException[[listings] script_score the script could not be loaded];
nested: ScriptException[dynamic scripting for [mvel] disabled]; }{[PxzZtO8FQviuhxS-3EJFwA][listings][0]:
SearchParseException[[listings][0]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"function_score": {
"script_score": {
"script": "_score * doc['random_score'].value"
}
}
}
}
]]];
nested: QueryParsingException[[listings] script_score the script could not be loaded];
nested: ScriptException[dynamic scripting for [mvel] disabled]; }{[PxzZtO8FQviuhxS-3EJFwA][listings][1]:
SearchParseException[[listings][1]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"function_score": {
"script_score": {
"script": "_score * doc['random_score'].value"
}
}
}
}
]]];
nested: QueryParsingException[[listings] script_score the script could not be loaded];
nested: ScriptException[dynamic scripting for [mvel] disabled]; }{[PxzZtO8FQviuhxS-3EJFwA][listings][2]:
SearchParseException[[listings][2]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"function_score": {
"script_score": {
"script": "_score * doc['random_score'].value"
}
}
}
}
]]];
nested: QueryParsingException[[listings] script_score the script could not be loaded];
nested: ScriptException[dynamic scripting for [mvel] disabled]; }]",
"status": 400
}
Something very simple such as this, works:
{
query: {
match_all: {}
}
}
In previous version mvel was scripting in elasticsearch, now depreciated.
Here is a issue for that. https://github.com/elasticsearch/elasticsearch/issues/7029
Actual problem is dynamic scripting for mvel is not supported in 1.3.x, but it is the default language in 1.3.x also, will be changed in 1.4.x, so you have to include lang parameter, and give value as, (lang=groovy)
{
query:{
function_score:{
script_score : {
"script" : "_score * doc['random_score'].value",
"lang":"groovy"
}
}
}
}
Hope this helps!! Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With