A newer version is available. For the latest information, see the
current release documentation.
Reverse token filter
editReverse token filter
editReverses each token in a stream. For example, you can use the reverse
filter
to change cat
to tac
.
Reversed tokens are useful for suffix-based searches,
such as finding words that end in -ion
or searching file names by their
extension.
This filter uses Lucene’s ReverseStringFilter.
Example
editThe following analyze API request uses the reverse
filter to reverse each token in quick fox jumps
:
GET _analyze { "tokenizer" : "standard", "filter" : ["reverse"], "text" : "quick fox jumps" }
The filter produces the following tokens:
[ kciuq, xof, spmuj ]
Add to an analyzer
editThe following create index API request uses the
reverse
filter to configure a new
custom analyzer.
PUT reverse_example { "settings" : { "analysis" : { "analyzer" : { "whitespace_reverse" : { "tokenizer" : "whitespace", "filter" : ["reverse"] } } } } }