Skip to content

Commit

Permalink
add uppercase token filter docs opensearch-project#8452
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Rubin <[email protected]>
  • Loading branch information
AntonEliatra committed Oct 3, 2024
1 parent 76486a4 commit 8d43849
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _analyzers/token-filters/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ Normalization | `arabic_normalization`: [ArabicNormalizer](https://lucene.apache
`trim` | [TrimFilter](https://lucene.apache.org/core/9_10_0/analysis/common/org/apache/lucene/analysis/miscellaneous/TrimFilter.html) | Trims leading and trailing white space from each token in a stream.
`truncate` | [TruncateTokenFilter](https://lucene.apache.org/core/9_10_0/analysis/common/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilter.html) | Truncates tokens whose length exceeds the specified character limit.
`unique` | N/A | Ensures each token is unique by removing duplicate tokens from a stream.
`uppercase` | [UpperCaseFilter](https://lucene.apache.org/core/9_10_0/analysis/common/org/apache/lucene/analysis/core/LowerCaseFilter.html) | Converts tokens to uppercase.
[`uppercase`]({{site.url}}{{site.baseurl}}/analyzers/token-filters/uppercase/) | [UpperCaseFilter](https://lucene.apache.org/core/9_10_0/analysis/common/org/apache/lucene/analysis/core/LowerCaseFilter.html) | Converts tokens to uppercase.
`word_delimiter` | [WordDelimiterFilter](https://lucene.apache.org/core/9_10_0/analysis/common/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilter.html) | Splits tokens at non-alphanumeric characters and performs normalization based on the specified rules.
`word_delimiter_graph` | [WordDelimiterGraphFilter](https://lucene.apache.org/core/9_10_0/analysis/common/org/apache/lucene/analysis/miscellaneous/WordDelimiterGraphFilter.html) | Splits tokens at non-alphanumeric characters and performs normalization based on the specified rules. Assigns multi-position tokens a `positionLength` attribute.
83 changes: 83 additions & 0 deletions _analyzers/token-filters/uppercase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
layout: default
title: Uppercase
parent: Token filters
nav_order: 460
---

# Uppercase token filter

The `uppercase` token filter is used to convert all tokens (words) to uppercase during analysis.

## Example

The following example request creates a new index named `uppercase_example` and configures an analyzer with `uppercase` filter:

```json
PUT /uppercase_example
{
"settings": {
"analysis": {
"filter": {
"uppercase_filter": {
"type": "uppercase"
}
},
"analyzer": {
"uppercase_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"uppercase_filter"
]
}
}
}
}
}
```
{% include copy-curl.html %}

## Generated tokens

Use the following request to examine the tokens generated using the analyzer:

```json
GET /uppercase_example/_analyze
{
"analyzer": "uppercase_analyzer",
"text": "OpenSearch is powerful"
}
```
{% 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": "POWERFUL",
"start_offset": 14,
"end_offset": 22,
"type": "<ALPHANUM>",
"position": 2
}
]
}
```

0 comments on commit 8d43849

Please sign in to comment.