Configuring built-in analyzers(配置内置分析器)

内置分析器可以直接使用,无需任何配置。然而,其中一些配置选项用来改变其行为。例如,standard(标准)分析器可以配置为支持停止词列表:

  1. PUT my_index
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "std_english": { #1
  7. "type": "standard",
  8. "stopwords": "_english_"
  9. }
  10. }
  11. }
  12. },
  13. "mappings": {
  14. "my_type": {
  15. "properties": {
  16. "my_text": {
  17. "type": "text",
  18. "analyzer": "standard", #2
  19. "fields": {
  20. "english": {
  21. "type": "text",
  22. "analyzer": "std_english" #3
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }}
  29. POST my_index/_analyze
  30. {
  31. "field": "my_text", #4
  32. "text": "The old brown cow"}
  33. POST my_index/_analyze
  34. {
  35. "field": "my_text.english", #5
  36. "text": "The old brown cow"}

| 1 | 我们将std_english分析器定义为基于standard(标准)分析器,但是配置为删除预定义的英文停止词列表。 | | 2,4 | my_text字段直接使用standard(标准)分析器,无需任何配置。这个字段没有停止词会被删除。所得的词语是:[the,old,brown,cow] | | 3,5 | my_text.english字段使用std_english分析器,因此英文停止词将被删除。得出的结论是:[old,brown.cow] |

原文链接 : https://www.elastic.co/guide/en/elasticsearch/reference/5.3/getting-started.html(修改该链接为官网对应的链接)

译文链接 : http://www.apache.wiki/display/Elasticsearch(修改该链接为 ApacheCN 对应的译文链接)

贡献者 : 曾少峰ApacheCNApache中文网