Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›Text analysis ›Token filter reference

Decimal digit token filter

Converts all digits in the Unicode Decimal_Number General Category to 0-9. For example, the filter changes the Bengali numeral ৩ to 3.

This filter uses Lucene’s DecimalDigitFilter.

Example

The following analyze API request uses the decimal_digit filter to convert Devanagari numerals to 0-9:

resp = client.indices.analyze(
    tokenizer="whitespace",
    filter=[
        "decimal_digit"
    ],
    text="१-one two-२ ३",
)
print(resp)
response = client.indices.analyze(
  body: {
    tokenizer: 'whitespace',
    filter: [
      'decimal_digit'
    ],
    text: '१-one two-२ ३'
  }
)
puts response
const response = await client.indices.analyze({
  tokenizer: "whitespace",
  filter: ["decimal_digit"],
  text: "१-one two-२ ३",
});
console.log(response);
GET /_analyze
{
  "tokenizer" : "whitespace",
  "filter" : ["decimal_digit"],
  "text" : "१-one two-२ ३"
}

The filter produces the following tokens:

[ 1-one, two-2, 3]

Add to an analyzer

The following create index API request uses the decimal_digit filter to configure a new custom analyzer.

resp = client.indices.create(
    index="decimal_digit_example",
    settings={
        "analysis": {
            "analyzer": {
                "whitespace_decimal_digit": {
                    "tokenizer": "whitespace",
                    "filter": [
                        "decimal_digit"
                    ]
                }
            }
        }
    },
)
print(resp)
response = client.indices.create(
  index: 'decimal_digit_example',
  body: {
    settings: {
      analysis: {
        analyzer: {
          whitespace_decimal_digit: {
            tokenizer: 'whitespace',
            filter: [
              'decimal_digit'
            ]
          }
        }
      }
    }
  }
)
puts response
const response = await client.indices.create({
  index: "decimal_digit_example",
  settings: {
    analysis: {
      analyzer: {
        whitespace_decimal_digit: {
          tokenizer: "whitespace",
          filter: ["decimal_digit"],
        },
      },
    },
  },
});
console.log(response);
PUT /decimal_digit_example
{
  "settings": {
    "analysis": {
      "analyzer": {
        "whitespace_decimal_digit": {
          "tokenizer": "whitespace",
          "filter": [ "decimal_digit" ]
        }
      }
    }
  }
}

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/analysis-decimal-digit-tokenfilter.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API