-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add limit token filter docs #8159
Merged
kolchfa-aws
merged 9 commits into
opensearch-project:main
from
AntonEliatra:add-limit-toke-filter-docs
Dec 2, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
54c9711
adding limit token filter docs
AntonEliatra 4e4e84d
removing parameter which is not working #8153
AntonEliatra 2b4899f
adding consume_all_tokens
AntonEliatra 9d46293
Update limit.md
AntonEliatra 2270743
updating parameter table
AntonEliatra 44f785d
Doc review
kolchfa-aws 7105763
Apply suggestions from code review
kolchfa-aws 2e718a0
Update _analyzers/token-filters/index.md
kolchfa-aws 8bf4f64
Merge branch 'main' into add-limit-toke-filter-docs
kolchfa-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,89 @@ | ||
--- | ||
layout: default | ||
title: Limit | ||
parent: Token filters | ||
nav_order: 250 | ||
--- | ||
|
||
# Limit token filter | ||
|
||
The `limit` token filter is used to limit the number of tokens passed through the analysis chain. | ||
|
||
## Parameters | ||
|
||
The `limit` token filter can be configured with the following parameters. | ||
|
||
Parameter | Required/Optional | Data type | Description | ||
:--- | :--- | :--- | :--- | ||
`max_token_count` | Optional | Integer | The maximum number of tokens to be generated. Default is `1`. | ||
`consume_all_tokens` | Optional | Boolean | (Expert-level setting) Uses all tokens from the tokenizer, even if the result exceeds `max_token_count`. When this parameter is set, the output still only contains the number of tokens specified by `max_token_count`. However, all tokens generated by the tokenizer are processed. Default is `false`. | ||
|
||
## Example | ||
|
||
The following example request creates a new index named `my_index` and configures an analyzer with a `limit` filter: | ||
|
||
```json | ||
PUT my_index | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"analyzer": { | ||
"three_token_limit": { | ||
"tokenizer": "standard", | ||
"filter": [ "custom_token_limit" ] | ||
} | ||
}, | ||
"filter": { | ||
"custom_token_limit": { | ||
"type": "limit", | ||
"max_token_count": 3 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Generated tokens | ||
|
||
Use the following request to examine the tokens generated using the analyzer: | ||
|
||
```json | ||
GET /my_index/_analyze | ||
{ | ||
"analyzer": "three_token_limit", | ||
"text": "OpenSearch is a powerful and flexible search engine." | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the generated tokens: | ||
|
||
```json | ||
{ | ||
"tokens": [ | ||
{ | ||
"token": "OpenSearch", | ||
"start_offset": 0, | ||
"end_offset": 10, | ||
"type": "<ALPHANUM>", | ||
"position": 0 | ||
}, | ||
{ | ||
"token": "is", | ||
"start_offset": 11, | ||
"end_offset": 13, | ||
"type": "<ALPHANUM>", | ||
"position": 1 | ||
}, | ||
{ | ||
"token": "a", | ||
"start_offset": 14, | ||
"end_offset": 15, | ||
"type": "<ALPHANUM>", | ||
"position": 2 | ||
} | ||
] | ||
} | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 19: What does "(Expect level setting)" mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expert 😄 Thanks for the catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YW, but should be "Expert-level setting" in that case 😄