-
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 stop analyzer docs #8534
Merged
kolchfa-aws
merged 8 commits into
opensearch-project:main
from
AntonEliatra:adding-stop-analyzer-docs
Dec 10, 2024
Merged
add stop analyzer docs #8534
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fa8cf9a
add stop analyzer docs
AntonEliatra 442edc5
adding more details
AntonEliatra 699429a
updating parameter table
AntonEliatra 473ae60
Doc review
kolchfa-aws 53ca45e
Update _analyzers/stop.md
kolchfa-aws e476e39
Update _analyzers/stop.md
kolchfa-aws 544265a
Add file path example
kolchfa-aws b87ab9d
Merge branch 'main' into adding-stop-analyzer-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
--- | ||
layout: default | ||
title: Stop analyzer | ||
nav_order: 70 | ||
--- | ||
|
||
# Stop analyzer | ||
|
||
The `stop` analyzer removes a predefined list of stopwords. This analyzer consists of a `lowercase` tokenizer and a `stop` token filter. | ||
|
||
## Parameters | ||
|
||
You can configure a `stop` analyzer with the following parameters. | ||
|
||
Parameter | Required/Optional | Data type | Description | ||
:--- | :--- | :--- | :--- | ||
`stopwords` | Optional | String or list of strings | A string specifying a predefined list of stopwords (such as `_english_`) or an array specifying a custom list of stopwords. Default is `_english_`. | ||
`stopwords_path` | Optional | String | The path (absolute or relative to the config directory) to the file containing a list of stop words. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Example | ||
|
||
Use the following command to create an index named `my_stop_index` with a `stop` analyzer: | ||
|
||
```json | ||
PUT /my_stop_index | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"my_field": { | ||
"type": "text", | ||
"analyzer": "stop" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Configuring a custom analyzer | ||
|
||
Use the following command to configure an index with a custom analyzer that is equivalent to a `stop` analyzer: | ||
|
||
```json | ||
PUT /my_custom_stop_analyzer_index | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"analyzer": { | ||
"my_custom_stop_analyzer": { | ||
"tokenizer": "lowercase", | ||
"filter": [ | ||
"stop" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"mappings": { | ||
"properties": { | ||
"my_field": { | ||
"type": "text", | ||
"analyzer": "my_custom_stop_analyzer" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Generated tokens | ||
|
||
Use the following request to examine the tokens generated using the analyzer: | ||
|
||
```json | ||
POST /my_custom_stop_analyzer_index/_analyze | ||
{ | ||
"analyzer": "my_custom_stop_analyzer", | ||
"text": "The large turtle is green and brown" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the generated tokens: | ||
|
||
```json | ||
{ | ||
"tokens": [ | ||
{ | ||
"token": "large", | ||
"start_offset": 4, | ||
"end_offset": 9, | ||
"type": "word", | ||
"position": 1 | ||
}, | ||
{ | ||
"token": "turtle", | ||
"start_offset": 10, | ||
"end_offset": 16, | ||
"type": "word", | ||
"position": 2 | ||
}, | ||
{ | ||
"token": "green", | ||
"start_offset": 20, | ||
"end_offset": 25, | ||
"type": "word", | ||
"position": 4 | ||
}, | ||
{ | ||
"token": "brown", | ||
"start_offset": 30, | ||
"end_offset": 35, | ||
"type": "word", | ||
"position": 6 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
# Specifying stopwords | ||
|
||
The following example request specifies a custom list of stopwords: | ||
|
||
```json | ||
PUT /my_new_custom_stop_index | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"analyzer": { | ||
"my_custom_stop_analyzer": { | ||
"type": "stop", | ||
"stopwords": ["is", "and", "was"] | ||
} | ||
} | ||
} | ||
}, | ||
"mappings": { | ||
"properties": { | ||
"description": { | ||
"type": "text", | ||
"analyzer": "my_custom_stop_analyzer" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} |
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.
I think it would be good to add an example where we would be using stopwords_path and format it expects
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.
Added