-
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 <anton.rubin@eliatra.com> * Doc review Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Anton Rubin <anton.rubin@eliatra.com> Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Fanit Kolchina <kolchfa@amazon.com> Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
- Loading branch information
1 parent
1026a84
commit 7bcd36c
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 | ||
} | ||
] | ||
} | ||
``` |