How can I pass parameters to token filter script in Elasticsearch?

I want to do something like the one below, but this code clearly does not work. Is there any way I can pass a predefined parameter to the "source" section?

term_temp = "of kerosene, kerosene fuel"
predicate_token_filter_temp = {
"type" : "predicate_token_filter",
"script" : {
"source": "String additional_terms = term_path ;String curr_token = toke n.getTerm().toString(); !curr_token.contains(" ") || additional_terms.contains(curr_token);",
"params": {"term_path": term_temp }

can you maybe explain in plain english what output you are expecting of what input, completely independent of any code snippet? This might be easier to understand what you are after.

I want to be able to pass parameters to "predicate_token_filter" token filter. In particularly, pass inside "source" section.
I'm trying to use String additional_terms = term_path but it does not work

that token filter can only see content from the particular field, not from other fields of the document.

Again a concrete use-case might be easier to understand your problem and possibly find a workaround.

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