加载中

配置内置分析器

内置分析器无需任何配置即可直接使用。不过,其中一些分析器支持通过配置选项来改变其行为。例如,可以配置 standard 分析器以支持停用词列表。

				PUT my-index-000001
					{
  "settings": {
    "analysis": {
      "analyzer": {
        "std_english": {
          "type":      "standard",
          "stopwords": "_english_"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "my_text": {
        "type":     "text",
        "analyzer": "standard",
        "fields": {
          "english": {
            "type":     "text",
            "analyzer": "std_english"
          }
        }
      }
    }
  }
}
				POST my-index-000001/_analyze
					{
  "field": "my_text",
  "text": "The old brown cow"
}
				POST my-index-000001/_analyze
					{
  "field": "my_text.english",
  "text": "The old brown cow"
}
		
  1. 我们将 std_english 分析器定义为基于 standard 分析器,但配置为移除预定义的英语停用词列表。
  2. my_text 字段直接使用 standard 分析器,无需任何配置。该字段不会移除任何停用词。生成的词元为:[ the, old, brown, cow ]
  3. my_text.english 字段使用 std_english 分析器,因此会移除英语停用词。生成的词元为:[ old, brown, cow ]
© . This website operates independently and is not affiliated with or endorsed by Elasticsearch B.V. All brand names, logos, and trademarks are the property of their respective owners.