15.1 自定义分词器

创建自定义分词器
测试分词器
DELETE /test_analyzer
PUT /test_analyzer
{
  "settings": {
    "analysis": {
      "char_filter": {
        "sign_to_word": {
          "type": "mapping",
          "mappings": ["&=> and","+=>add"]
        }
      },
      "filter": {
        "my_stopwords": {
          "type": "stop",
          "stopwords": ["the", "a", "her", "his"]
        }
      },
      "analyzer": {
        "my_analyzer": {
          "type": "custom",
          "char_filter": ["html_strip", "sign_to_word"],
          "tokenizer": "standard",
          "filter": ["lowercase", "my_stopwords"]
        }
      }
    }
  }
}
 
GET /test_analyzer/_analyze
{
  "text": "ruru is a her HAHA!!!",
  "analyzer": "my_analyzer"
}

你可能感兴趣的:(15.1 自定义分词器)