Elastic Search Backend : pushing a conditional filter

Hi,

At boostrap, some settings are pushed to elastic search : analyser/filter/tokenizers.
But this time, I’am stucked on one filter I don’t manage to send :
[Conditional token filter | Elasticsearch Guide [8.2] | Elastic](The conditionnal filter)

 context.tokenFilter("quote_condition")
                .type("condition")
                .param("script", "{ \"source\": \"return token.getPosition() > 0\"}");

I don’t find the value syntax for the script param. I attempted a lot of syntax yet :

.param("script", "{ \\\"source\\\": \\\"return token.getPosition() > 0\\\"}");

.param("script", "{\\\"script\\\": { \\\"source\\\": \\\"return token.getPosition() > 0\\\"}}");

.param("script", "{\"script\": { \"source\": \"return token.getPosition() > 0\"}}");

The error message is always the same :

"error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "must specify either [source] for an inline script or [id] for a stored script"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "must specify either [source] for an inline script or [id] for a stored script"
  },

Any idea of the value syntax ?

Thank you.

Hi,

There is no way to do this with the Elasticsearch analysis configurer at the moment.

Please open a ticket on JIRA.

As a workaround, you can define some analysis settings in a JSON file and have Hibernate Search merge that with the other settings (including those from your ElasticsearchAnalysisConfigurer: you can mix the two approaches).

Ok I will know then. Thanks.