elasticsearch 自定义 analyzer

柔情痞子 提交于 2020-03-16 22:25:48

某厂面试归来,发现自己落伍了!>>>

示例:

# mapping 中自定义 analyzer

## char_filter
# html_strip
POST _analyze
{
  "tokenizer": "keyword",
  "char_filter": ["html_strip"],
  "text": "<b>hello world</b>"
}

# mapping
POST _analyze
{
  "tokenizer": "standard", 
  "char_filter": [
    {
      "type": "mapping",
      "mappings": ["-=>_"]
    }
  ], 
  "text": "123-456, i-test"
}

# 正则表达式
POST _analyze
{
  "tokenizer": "standard",
  "char_filter": [
    {
      "type": "pattern_replace",
      "pattern": "http://(.*)",
      "replacement": "$1"
    }
  ],
  "text": "http://www.elastic.co"
}

## tokenizer
# path_hierarchy
POST _analyze
{
  "tokenizer": "path_hierarchy",
  "text": "/usr/abc/efg"
}

## filter
# whitespace and stop
POST _analyze
{
  "tokenizer": "whitespace",
  "filter": ["stop"],
  "text": "The rain in Spain falls mainly on the plain."
}

POST _analyze
{
  "tokenizer": "whitespace",
  "filter": ["lowercase", "stop"],
  "text": "The rain in Spain falls mainly on the plain."
}




 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!