Decimal digit token filter

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:

  1. resp = client.indices.analyze(
  2. tokenizer="whitespace",
  3. filter=[
  4. "decimal_digit"
  5. ],
  6. text="१-one two-२ ३",
  7. )
  8. print(resp)
  1. response = client.indices.analyze(
  2. body: {
  3. tokenizer: 'whitespace',
  4. filter: [
  5. 'decimal_digit'
  6. ],
  7. text: '१-one two-२ ३'
  8. }
  9. )
  10. puts response
  1. const response = await client.indices.analyze({
  2. tokenizer: "whitespace",
  3. filter: ["decimal_digit"],
  4. text: "१-one two-२ ३",
  5. });
  6. console.log(response);
  1. GET /_analyze
  2. {
  3. "tokenizer" : "whitespace",
  4. "filter" : ["decimal_digit"],
  5. "text" : "१-one two-२ ३"
  6. }

The filter produces the following tokens:

  1. [ 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.

  1. resp = client.indices.create(
  2. index="decimal_digit_example",
  3. settings={
  4. "analysis": {
  5. "analyzer": {
  6. "whitespace_decimal_digit": {
  7. "tokenizer": "whitespace",
  8. "filter": [
  9. "decimal_digit"
  10. ]
  11. }
  12. }
  13. }
  14. },
  15. )
  16. print(resp)
  1. response = client.indices.create(
  2. index: 'decimal_digit_example',
  3. body: {
  4. settings: {
  5. analysis: {
  6. analyzer: {
  7. whitespace_decimal_digit: {
  8. tokenizer: 'whitespace',
  9. filter: [
  10. 'decimal_digit'
  11. ]
  12. }
  13. }
  14. }
  15. }
  16. }
  17. )
  18. puts response
  1. const response = await client.indices.create({
  2. index: "decimal_digit_example",
  3. settings: {
  4. analysis: {
  5. analyzer: {
  6. whitespace_decimal_digit: {
  7. tokenizer: "whitespace",
  8. filter: ["decimal_digit"],
  9. },
  10. },
  11. },
  12. },
  13. });
  14. console.log(response);
  1. PUT /decimal_digit_example
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "whitespace_decimal_digit": {
  7. "tokenizer": "whitespace",
  8. "filter": [ "decimal_digit" ]
  9. }
  10. }
  11. }
  12. }
  13. }