NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Predicate Token Filter Script
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Predicate Token Filter Script
editThe predicate_token_filter token filter takes a predicate script, and removes tokens that do not match the predicate.
Options
edit|
script |
a predicate script that determines whether or not the current token will be emitted. 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_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: