Link Search Menu Expand Document Documentation Menu

撇号分词过滤器

撇号分词过滤器的主要功能是移除所有格撇号及其后面的内容。这在分析大量使用撇号的语言(如土耳其语)文本时非常有用,因为在土耳其语中,撇号将词根与后缀(包括所有格后缀、格标记和其他语法结尾)分开。

示例

以下示例请求创建一个名为 custom_text_index 的新索引,该索引在 settings 中配置了自定义分析器并在 mappings 中使用。

PUT /custom_text_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "custom_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "apostrophe"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "custom_analyzer"
      }
    }
  }
}

生成的词元

使用以下请求检查使用创建的分析器生成的词元。

POST /custom_text_index/_analyze
{
  "analyzer": "custom_analyzer",
  "text": "John's car is faster than Peter's bike"
}

响应包含生成的词元

{
  "tokens": [
    {
      "token": "john",
      "start_offset": 0,
      "end_offset": 6,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "car",
      "start_offset": 7,
      "end_offset": 10,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "is",
      "start_offset": 11,
      "end_offset": 13,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "faster",
      "start_offset": 14,
      "end_offset": 20,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "than",
      "start_offset": 21,
      "end_offset": 25,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "peter",
      "start_offset": 26,
      "end_offset": 33,
      "type": "<ALPHANUM>",
      "position": 5
    },
    {
      "token": "bike",
      "start_offset": 34,
      "end_offset": 38,
      "type": "<ALPHANUM>",
      "position": 6
    }
  ]
}

内置的 撇号分词过滤器不适用于法语等在词首使用撇号的语言。例如,"C'est l'amour de l'école" 将产生四个词元:“C”、“l”、“de”和“l”。

剩余 350 字符

有问题?

想贡献?