-
Notifications
You must be signed in to change notification settings - Fork 500
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 porter stem token filter docs #8271 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 5e2fc78) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
22c0d7e
commit 80fee2b
Showing
2 changed files
with
84 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,83 @@ | ||
--- | ||
layout: default | ||
title: Porter stem | ||
parent: Token filters | ||
nav_order: 340 | ||
--- | ||
|
||
# Porter stem token filter | ||
|
||
The `porter_stem` token filter reduces words to their base (or _stem_) form and removes common suffixes from words, which helps in matching similar words by their root. For example, the word `running` is stemmed to `run`. This token filter is primarily used for the English language and provides stemming based on the [Porter stemming algorithm](https://snowballstem.org/algorithms/porter/stemmer.html). | ||
|
||
|
||
## Example | ||
|
||
The following example request creates a new index named `my_stem_index` and configures an analyzer with a `porter_stem` filter: | ||
|
||
```json | ||
PUT /my_stem_index | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"filter": { | ||
"my_porter_stem": { | ||
"type": "porter_stem" | ||
} | ||
}, | ||
"analyzer": { | ||
"porter_analyzer": { | ||
"tokenizer": "standard", | ||
"filter": [ | ||
"lowercase", | ||
"my_porter_stem" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Generated tokens | ||
|
||
Use the following request to examine the tokens generated using the analyzer: | ||
|
||
```json | ||
POST /my_stem_index/_analyze | ||
{ | ||
"text": "running runners ran", | ||
"analyzer": "porter_analyzer" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the generated tokens: | ||
|
||
```json | ||
{ | ||
"tokens": [ | ||
{ | ||
"token": "run", | ||
"start_offset": 0, | ||
"end_offset": 7, | ||
"type": "<ALPHANUM>", | ||
"position": 0 | ||
}, | ||
{ | ||
"token": "runner", | ||
"start_offset": 8, | ||
"end_offset": 15, | ||
"type": "<ALPHANUM>", | ||
"position": 1 | ||
}, | ||
{ | ||
"token": "ran", | ||
"start_offset": 16, | ||
"end_offset": 19, | ||
"type": "<ALPHANUM>", | ||
"position": 2 | ||
} | ||
] | ||
} | ||
``` |