原文地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/analysis-predicatefilter-tokenfilter.html, 原文档版权归 www.elastic.co 所有
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Predicate script token filteredit
The predicate_token_filter token filter takes a predicate script, and removes tokens that do not match the predicate.
Optionsedit
script |
a predicate script that determines whether or not the current token will be emitted. Note that only inline scripts are supported. |
Settings exampleedit
You can set it up like:
PUT /condition_example { "settings" : { "analysis" : { "analyzer" : { "my_analyzer" : { "tokenizer" : "standard", "filter" : [ "my_script_filter" ] } }, "filter" : { "my_script_filter" : { "type" : "predicate_token_filter", "script" : { "source" : "token.getTerm().length() > 5" } } } } } }
And test it like:
POST /condition_example/_analyze { "analyzer" : "my_analyzer", "text" : "What Flapdoodle" }
And it’d respond: