`
m635674608
  • 浏览: 4930623 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

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

 

 

 

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=番茄

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics