-
Notifications
You must be signed in to change notification settings - Fork 508
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 fingerprint token filter #7982 Signed-off-by: Anton Rubin <anton.rubin@eliatra.com> * fixing typo Signed-off-by: Anton Rubin <anton.rubin@eliatra.com> * Update fingerprint.md Signed-off-by: AntonEliatra <anton.rubin@eliatra.com> * updating parameter table Signed-off-by: Anton Rubin <anton.rubin@eliatra.com> * Apply suggestions from code review Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Signed-off-by: AntonEliatra <anton.rubin@eliatra.com> * Update _analyzers/token-filters/fingerprint.md 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: AntonEliatra <anton.rubin@eliatra.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Nathan Bower <nbower@amazon.com> (cherry picked from commit b0a56c1) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
aa5da3b
commit 0027131
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
layout: default | ||
title: Fingerprint | ||
parent: Token filters | ||
nav_order: 140 | ||
--- | ||
|
||
# Fingerprint token filter | ||
|
||
The `fingerprint` token filter is used to standardize and deduplicate text. This is particularly useful when consistency in text processing is crucial. The `fingerprint` token filter achieves this by processing text using the following steps: | ||
|
||
1. **Lowercasing**: Converts all text to lowercase. | ||
Check failure on line 12 in _analyzers/token-filters/fingerprint.md GitHub Actions / vale[vale] _analyzers/token-filters/fingerprint.md#L12
Raw output
|
||
2. **Splitting**: Breaks the text into tokens. | ||
3. **Sorting**: Arranges the tokens in alphabetical order. | ||
4. **Removing duplicates**: Eliminates repeated tokens. | ||
5. **Joining tokens**: Combines the tokens into a single string, typically joined by a space or another specified separator. | ||
|
||
## Parameters | ||
|
||
The `fingerprint` token filter can be configured with the following two parameters. | ||
|
||
Parameter | Required/Optional | Data type | Description | ||
:--- | :--- | :--- | :--- | ||
`max_output_size` | Optional | Integer | Limits the length of the generated fingerprint string. If the concatenated string exceeds the `max_output_size`, the filter will not produce any output, resulting in an empty token. Default is `255`. | ||
`separator` | Optional | String | Defines the character(s) used to join the tokens into a single string after they have been sorted and deduplicated. Default is space (`" "`). | ||
|
||
## Example | ||
|
||
The following example request creates a new index named `my_index` and configures an analyzer with a `fingerprint` token filter: | ||
|
||
```json | ||
PUT /my_index | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"filter": { | ||
"my_fingerprint": { | ||
"type": "fingerprint", | ||
"max_output_size": 200, | ||
"separator": "-" | ||
} | ||
}, | ||
"analyzer": { | ||
"my_analyzer": { | ||
"type": "custom", | ||
"tokenizer": "standard", | ||
"filter": [ | ||
"lowercase", | ||
"my_fingerprint" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Generated tokens | ||
|
||
Use the following request to examine the tokens generated using the analyzer: | ||
|
||
```json | ||
POST /my_index/_analyze | ||
{ | ||
"analyzer": "my_analyzer", | ||
"text": "OpenSearch is a powerful search engine that scales easily" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the generated tokens: | ||
|
||
```json | ||
{ | ||
"tokens": [ | ||
{ | ||
"token": "a-easily-engine-is-opensearch-powerful-scales-search-that", | ||
"start_offset": 0, | ||
"end_offset": 57, | ||
"type": "fingerprint", | ||
"position": 0 | ||
} | ||
] | ||
} | ||
``` |
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