Error SearchScript.CONTEXT == false

Hello!
I am creating a custom plugin and when making this query I have this error.

JSON

GET example_event/_search
{
  "query": {
    "bool" : {
      "filter" : {
        "script" : {
          "script" : {
            "source": "notHasExpired",
            "lang": "native",
            "params": {
              "field": "recurrent_date"
            }
          }
        }
      }
    }
  }
}

Error

"caused_by": {
      "type": "general_script_exception",
      "reason": "Failed to compile inline script [notHasExpired] using lang [native]",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "native scripts can not be used for context [filter]"
      }
    }

If code

if (context.equals(SearchScript.CONTEXT) == false) {
                //throw new IllegalArgumentException(getType() + " scripts cannot be used for context [" + context.name + "]");
            }

where compile receives
ScriptName: notHasExpired
scriptSource: notHasExpired
ContextType: native
ContextName: filter
SearchScript.CONTEXT: org.elasticsearch.script.ScriptContext@3e5d4f6b

if I delete the condition of "SearchScript.CONTEXT == false" I have an error of "org.elasticsearch.script.FilterScript $ Factory" but I am using it is "SearchScript.Factory factory = hasAnyOccurrenceBetween :: new;"

Do you have any idea why?

Since you are within a filter bool clause, the script type is FilterScript.

Hello boy. if so I had to set the same script for each of the clauses. But now I have a problem since the same scripts I need to set it in agregation. What is the "import org.elasticsearch.script.?" to use?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.