十进制数字标记过滤器

编辑

将 Unicode Decimal_Number 通用类别中的所有数字转换为 0-9。例如,该过滤器将孟加拉数字 更改为 3

此过滤器使用 Lucene 的 DecimalDigitFilter

示例

编辑

以下 分析 API 请求使用 decimal_digit 过滤器将 Devanagari 数字转换为 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-२ ३"
}

过滤器生成以下标记:

[ 1-one, two-2, 3]

添加到分析器

编辑

以下 创建索引 API 请求使用 decimal_digit 过滤器来配置新的 自定义分析器

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" ]
        }
      }
    }
  }
}