-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* adding reverse token filter docs #8274 Signed-off-by: Anton Rubin <[email protected]> * Doc review Signed-off-by: Fanit Kolchina <[email protected]> * Apply suggestions from code review Co-authored-by: Nathan Bower <[email protected]> Signed-off-by: kolchfa-aws <[email protected]> --------- Signed-off-by: Anton Rubin <[email protected]> Signed-off-by: Fanit Kolchina <[email protected]> Signed-off-by: kolchfa-aws <[email protected]> Co-authored-by: Fanit Kolchina <[email protected]> Co-authored-by: kolchfa-aws <[email protected]> Co-authored-by: Nathan Bower <[email protected]> (cherry picked from commit 7bcd36c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
51edf18
commit f49f2f8
Showing
2 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
layout: default | ||
title: Reverse | ||
parent: Token filters | ||
nav_order: 360 | ||
--- | ||
|
||
# Reverse token filter | ||
|
||
The `reverse` token filter reverses the order of the characters in each token, making suffix information accessible at the beginning of the reversed tokens during analysis. | ||
|
||
This is useful for suffix-based searches: | ||
|
||
The `reverse` token filter is useful when you need to perform suffix-based searches, such as in the following scenarios: | ||
|
||
- **Suffix matching**: Searching for words based on their suffixes, such as identifying words with a specific ending (for example, `-tion` or `-ing`). | ||
- **File extension searches**: Searching for files by their extensions, such as `.txt` or `.jpg`. | ||
- **Custom sorting or ranking**: By reversing tokens, you can implement unique sorting or ranking logic based on suffixes. | ||
- **Autocomplete for suffixes**: Implementing autocomplete suggestions that use suffixes rather than prefixes. | ||
|
||
|
||
## Example | ||
|
||
The following example request creates a new index named `my-reverse-index` and configures an analyzer with a `reverse` filter: | ||
|
||
```json | ||
PUT /my-reverse-index | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"filter": { | ||
"reverse_filter": { | ||
"type": "reverse" | ||
} | ||
}, | ||
"analyzer": { | ||
"my_reverse_analyzer": { | ||
"type": "custom", | ||
"tokenizer": "standard", | ||
"filter": [ | ||
"lowercase", | ||
"reverse_filter" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Generated tokens | ||
|
||
Use the following request to examine the tokens generated using the analyzer: | ||
|
||
```json | ||
GET /my-reverse-index/_analyze | ||
{ | ||
"analyzer": "my_reverse_analyzer", | ||
"text": "hello world" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the generated tokens: | ||
|
||
```json | ||
{ | ||
"tokens": [ | ||
{ | ||
"token": "olleh", | ||
"start_offset": 0, | ||
"end_offset": 5, | ||
"type": "<ALPHANUM>", | ||
"position": 0 | ||
}, | ||
{ | ||
"token": "dlrow", | ||
"start_offset": 6, | ||
"end_offset": 11, | ||
"type": "<ALPHANUM>", | ||
"position": 1 | ||
} | ||
] | ||
} | ||
``` |