forked from opensearch-project/documentation-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add kstem token filter docs opensearch-project#8150
Signed-off-by: Anton Rubin <[email protected]>
- Loading branch information
1 parent
76486a4
commit 3b71e8a
Showing
2 changed files
with
89 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,88 @@ | ||
--- | ||
layout: default | ||
title: Kstem | ||
parent: Token filters | ||
nav_order: 220 | ||
--- | ||
|
||
# Kstem token filter | ||
|
||
The `length` token filter is a stemming filter used to reduce words to their root forms. The KStem filter is a lightweight, algorithmic stemmer designed for the English language, performing the following stemming: | ||
|
||
- Reduces plurals to singular form. | ||
- Converts different tenses of verbs to their base form. | ||
- Removes common derivational endings such as "-ing", "-ed". | ||
|
||
## Example | ||
|
||
The following example request creates a new index named `my_kstem_index` and configures an analyzer with `kstem` filter: | ||
|
||
```json | ||
PUT /my_kstem_index | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"filter": { | ||
"kstem_filter": { | ||
"type": "kstem" | ||
} | ||
}, | ||
"analyzer": { | ||
"my_kstem_analyzer": { | ||
"type": "custom", | ||
"tokenizer": "standard", | ||
"filter": [ | ||
"lowercase", | ||
"kstem_filter" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"mappings": { | ||
"properties": { | ||
"content": { | ||
"type": "text", | ||
"analyzer": "my_kstem_analyzer" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Generated tokens | ||
|
||
Use the following request to examine the tokens generated using the created analyzer: | ||
|
||
```json | ||
POST /my_kstem_index/_analyze | ||
{ | ||
"analyzer": "my_kstem_analyzer", | ||
"text": "stops stopped" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the generated tokens: | ||
|
||
```json | ||
{ | ||
"tokens": [ | ||
{ | ||
"token": "stop", | ||
"start_offset": 0, | ||
"end_offset": 5, | ||
"type": "<ALPHANUM>", | ||
"position": 0 | ||
}, | ||
{ | ||
"token": "stop", | ||
"start_offset": 6, | ||
"end_offset": 13, | ||
"type": "<ALPHANUM>", | ||
"position": 1 | ||
} | ||
] | ||
} | ||
``` |