Token filter predicate script and query-time 'params'

Hello!

I have been spelunking through Elastic code to try to understand how the following is possible. The Analysis Predicate Context says that painless scripts run at analysis can accept query-time params"

params ( Map , read-only)

User-defined parameters passed in as part of the query.

However, I'm unable to figure out if this is actually true or not. Because the "script" body appears as a mapping definition, I would not expect to be able to pass "params" anywhere (there's no specific place in a query to pass in query time params for analysis scripts?)

Indeed in the associated PR, I do not see any reference to "Query Time Params"

I was hoping that this note in the docs pointed at a way to change analyzer settings per-query (aside from changing the analyzer itself. But I don't see any such code, and given my knowledge of Lucene, etc, I wouldn't expect to find an ability to change analyzer internal params per query.

Is this correct? I just want to confirm my understanding that the docs may actually be incorrect here?

Happy to send in a PR of course, just want to confirm :slight_smile:

In general, script has the structure:

{
  "script":{
    "source": "<some script>",
    "params": {<params map>}
  }
}

So I suppose Predicate script token filter can contain params paramter. Do I undestand your question correctly??

Yes!

My question is more a clarification

  • The script is defined at index time
  • The "params" say they are passed at query time

But I think params are really defined in the context the script is used, and in the case of analyzers, you can't really pass params along with the query that uses the analyzer itself...

I found you are right. I tried some places (index settings, field settings and in query), and I couldn't pass params to script everywhere..

@softwaredoug The documentation is wrong, this context does not take params. We'll update the documentation.

What are you trying to achieve with params here?

1 Like

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