es Synonyms filter

put /my_index3
{
  "settings": {
    "analysis": {
      "filter": {
        "my_synonym_filter": {
          "type": "synonym", 
          "synonyms": [ 
            "中国,天朝",
            "北京,京城"
          ]
        }
      },
      "analyzer": {
        "my_synonyms": {
          "tokenizer": "ik",
          "filter": [
            "lowercase",
            "my_synonym_filter" 
          ]
        }
      }
    }
  }
}

   

   

put /my_index3  
{  
  "settings": {  
    "analysis": {  
      "filter": {  
        "my_synonym_filter": {  
          "type": "synonym",   
          "synonyms_path": "analysis/synonym.txt"
        }  
      },  
      "analyzer": {  
        "my_synonyms": {  
          "tokenizer": "ik",  
          "filter": [  
            "lowercase",  
            "my_synonym"   
          ]  
        }  
      }  
    }  
  }  
}  

 

 

http://localhost:9200/my_index2/_analyze?analyzer=my_synonyms&text=天朝 北京

 

   

    "tokens": [
        {
            "token": "中国", 
            "start_offset": 0, 
            "end_offset": 2, 
            "type": "SYNONYM", 
            "position": 1
        }, 
        {
            "token": "天朝", 
            "start_offset": 0, 
            "end_offset": 2, 
            "type": "SYNONYM", 
            "position": 1
        }, 
        {
            "token": "朝", 
            "start_offset": 1, 
            "end_offset": 2, 
            "type": "CN_WORD", 
            "position": 2
        }, 
        {
            "token": "北京", 
            "start_offset": 3, 
            "end_offset": 5, 
            "type": "SYNONYM", 
            "position": 3
        }, 
        {
            "token": "京城", 
            "start_offset": 3, 
            "end_offset": 5, 
            "type": "SYNONYM", 
            "position": 3
        }, 
        {
            "token": "京", 
            "start_offset": 4, 
            "end_offset": 5, 
            "type": "CN_WORD", 
            "position": 4
        }
    ]
}

 https://www.elastic.co/guide/en/elasticsearch/guide/current/using-synonyms.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html

 

 

 

扫描二维码关注公众号,回复: 723592 查看本文章

http://localhost:9200/zzm/_analyze?analyzer=ik&text=中华人民共和国

http://localhost:9200/zzm/_analyze?analyzer=mmseg&text=中华人民共和国

http://localhost:9200/zzm/_analyze?analyzer=pinyin&text=中华人民共和国

http://localhost:9200/zzm/_analyze?field=content&text=中华人民共和国

http://localhost:9200/my_index/_analyze?analyzer=my_synonyms&text=Elizabeth is the English queen

http://localhost:9200/my_index2/_analyze?analyzer=my_synonyms&text=天朝 北京

http://localhost:9200/my_index2/_analyze?analyzer=my_synonyms&text=布鼓雷门

http://localhost:9200/zzm/_analyze?analyzer=ik_max_word_syno&text=番茄

http://localhost:9200/zzm/_analyze?analyzer=ik_max_word_syno&text=es 

http://localhost:9200/synonym/_analyze?analyzer=mmseg_synonym&text=番茄

猜你喜欢

转载自m635674608.iteye.com/blog/2261199
今日推荐