撇号词元过滤器

编辑

删除撇号后的所有字符,包括撇号本身。

此过滤器包含在 Elasticsearch 的内置 土耳其语分析器 中。它使用 Lucene 的 ApostropheFilter,该过滤器是为土耳其语构建的。

示例

编辑

以下 analyze API 请求演示了撇号词元过滤器的工作方式。

resp = client.indices.analyze(
    tokenizer="standard",
    filter=[
        "apostrophe"
    ],
    text="Istanbul'a veya Istanbul'dan",
)
print(resp)
response = client.indices.analyze(
  body: {
    tokenizer: 'standard',
    filter: [
      'apostrophe'
    ],
    text: "Istanbul'a veya Istanbul'dan"
  }
)
puts response
const response = await client.indices.analyze({
  tokenizer: "standard",
  filter: ["apostrophe"],
  text: "Istanbul'a veya Istanbul'dan",
});
console.log(response);
GET /_analyze
{
  "tokenizer" : "standard",
  "filter" : ["apostrophe"],
  "text" : "Istanbul'a veya Istanbul'dan"
}

该过滤器生成以下词元

[ Istanbul, veya, Istanbul ]

添加到分析器

编辑

以下 create index API 请求使用撇号词元过滤器配置一个新的 自定义分析器

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