IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Conditional Token Filter
editConditional Token Filter
editThe conditional token filter takes a predicate script and a list of subfilters, and only applies the subfilters to the current token if it matches the predicate.
Options
edit
filter |
a chain of token filters to apply to the current token if the predicate matches. These can be any token filters defined elsewhere in the index mappings. |
script |
a predicate script that determines whether or not the filters will be applied to the current token. Note that only inline scripts are supported |
Settings example
editYou can set it up like:
PUT /condition_example { "settings" : { "analysis" : { "analyzer" : { "my_analyzer" : { "tokenizer" : "standard", "filter" : [ "my_condition" ] } }, "filter" : { "my_condition" : { "type" : "condition", "filter" : [ "lowercase" ], "script" : { "source" : "token.getTerm().length() < 5" } } } } } }
And test it like:
POST /condition_example/_analyze { "analyzer" : "my_analyzer", "text" : "What Flapdoodle" }
And it’d respond: