标签:
集群环境如下:
开发环境:
curl -XPUT http://localhost:9200/medcl/ -d‘{"index" : {"analysis" : {"analyzer" : {"pinyin_analyzer" : {"tokenizer" : "my_pinyin","filter" : ["standard"]}},"tokenizer" : {"my_pinyin" : {"type" : "pinyin","first_letter" : "none","padding_char" : " "}}}}}‘
http://10.110.13.144:9200/medcl/_analyze?text=%E5%88%98%E5%BE%B7%E5%8D%8E&analyzer=pinyin_analyzer
若测试成功,浏览器返回结果如下:
{"tokens":[{"token":"liudehua","start_offset":0,"end_offset":3,"type":"word","position":0}]}
curl -XPOST http://localhost:9200/medcl/_closecurl -XPUT http://localhost:9200/medcl/_settings -d‘{"index" : {"analysis" : {"analyzer" : {"pinyin_analyzer" : {"tokenizer" : "my_pinyin","filter" : ["standard"],"type":"pinyin"}},"tokenizer" : {"my_pinyin" : {"type" : "pinyin","first_letter" : "none","padding_char" : " "}}}}}‘curl -XPOST http://localhost:9200/medcl/_open
curl -XPOST http://localhost:9200/medcl/folks/_mapping -d‘{"folks": {"properties": {"name": {"type": "multi_field","fields": {"name": {"type": "string","store": "no","term_vector": "with_positions_offsets","analyzer": "pinyin_analyzer","boost": 10},"primitive": {"type": "string","store": "yes","analyzer": "keyword"}}}}}}‘
curl -XPOST http://localhost:9200/medcl/folks/andy -d‘{"name":"刘德华"}‘
http://10.110.13.144:9200/medcl/folks/_search?q=name:liudehua
若检索成功,浏览器返回以下结果:
{"took":9,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":3.0685282,"hits":[{"_index":"pinyin","_type":"test","_id":"andy","_score":3.0685282,"_source":{"name":"刘德华"}}]}}
标签:
原文地址:http://www.cnblogs.com/myitroad/p/5901629.html