Why am I getting an error in my ElasticSearch request after upgrading to 1.3.2?

I used to have this:

{
  query: {
    function_score: {
      filter: {
        and: [
          {
            term: {
              'currency': 'usd',
              '_cache': false
            }
          }
        ]
      },
      script_score: {
        "script": "_score * doc['random_score'].value"
      }
    }
  }
}

      

Very simple, I just filter the currency and sort by invoice.

But every time I update I can't get a simple custom counting query to work.

I tried to simplify it with this example:

{
  query: {
    function_score: {
      script_score: {
        "script": "_score * doc['random_score'].value"
      }
    }
  }
}

      

And I am getting errors like:

{
  "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 like this works:

{
  query: {
    match_all: {}
  }
}

      

+3


source to share


1 answer


In the previous version, mvel scripted in elasticsearch, now depreciated.

That's the problem for that. https://github.com/elasticsearch/elasticsearch/issues/7029

The actual problem is dynamic scripting for mvel, which is not supported in the 1.3.x file, but this default language in 1.3.x will also be changed in 1.4.x, so you need to include the lang parameter and specify the value as, (lang = groovy )



{
    query:{
        function_score:{
            script_score : {
                "script" : "_score * doc['random_score'].value",
                "lang":"groovy"
            }
        }
   }
} 

      

Hope this helps! Thanks to

+12


source







All Articles