分析器参数
> 文档中心 > 文档中心 > INFINI Easysearch > 功能手册 > 文档建模 > 文档映射 > 分析器参数

Analyzer 分析器参数 #

分析器 analyzer 映射参数用于定义在索引和搜索期间应用于文本字段的文本分析过程,即分词器的作用过程。

代码样例 #

以下示例配置定义了一个名为 my_custom_analyzer 的自定义分词器:

PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_custom_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "my_stop_filter",
            "my_stemmer"
          ]
        }
      },
      "filter": {
        "my_stop_filter": {
          "type": "stop",
          "stopwords": ["the", "a", "and", "or"]
        },
        "my_stemmer": {
          "type": "stemmer",
          "language": "english"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "my_text_field": {
        "type": "text",
        "analyzer": "my_custom_analyzer",
        "search_analyzer": "standard",
        "search_quote_analyzer": "my_custom_analyzer"
      }
    }
  }
}

在此示例中,my_custom_analyzer 使用标准分词器,将所有标记转换为小写,应用自定义停用词过滤器,并应用英语词干提取器。

您可以映射一个文本字段,使其在索引和搜索操作中都使用此自定义分词器:

"mappings": {
  "properties": {
    "my_text_field": {
      "type": "text",
      "analyzer": "my_custom_analyzer"
    }
  }
}