Standard Tokenizer(标准分词器)

standard tokenizer(标准分词器)提供基于语法的分词(基于Unicode文本分割算法,如 Unicode标准附件29 中所述),并且适用于大多数语言。

原文链接 : https://www.elastic.co/guide/en/elasticsearch/reference/5.3/analysis-standard-tokenizer.html

译文链接 : http://www.apache.wiki/pages/viewpage.action?pageId=9405453

贡献者 : 陈益雷ApacheCNApache中文网

输出示例

  1. POST _analyze
  2. {
  3. "tokenizer": "standard",
  4. "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
  5. }

上面的句子会生成如下的词元:

  1. [ The, 2, QUICK, Brown, Foxes, jumped, over, the, lazy, dog's, bone ]

配置

standard tokenizer(标准分词器) 接受以下参数:

max_token_length 单个 token 的最大长度。如果一个 token 超过这个长度,则以 max_token_length 为间隔分割。默认值是 255.。

配置示例

下面的例子中,我们配置标准分词器的 _**max_token_length**_ 为 5 (便于展示):

  1. PUT my_index
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "my_analyzer": {
  7. "tokenizer": "my_tokenizer"
  8. }
  9. },
  10. "tokenizer": {
  11. "my_tokenizer": {
  12. "type": "standard",
  13. "max_token_length": 5
  14. }
  15. }
  16. }
  17. }
  18. }
  19. POST my_index/_analyze
  20. {
  21. "analyzer": "my_analyzer",
  22. "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
  23. }

输出如下:

  1. [ The, 2, QUICK, Brown, Foxes, jumpe, d, over, the, lazy, dog's, bone ]