Elasticsearch2.1.0安装中文分词插件ik1.6
2015-12-16 16:51
501 查看
1、到github网站下载源代码,网站地址为:https://github.com/medcl/elasticsearch-analysis-ik
2、将解压目录文件中config/ik文件夹复制到ES安装目录config文件夹下。
3、将打包得到的zip文件解压,复制elasticsearch-analysis-ik-1.6.0.jar、httpclient-4.4.1.jar、httpcore-4.4.1.jar(仓库拷贝)到ES安装目录的lib目录下。
4、在ES的plugins目录下建立ik文件夹,将打包文件中的plugin-descriptor.properties(elasticsearch-analysis-ik-master\src\main\resources)拷贝进去
重新启动elasticsearch服务,这样就完成配置了,收入命令:
[html] view
plaincopy
curl -XPOST "http://localhost:9200/userinfo/_analyze?analyzer=ik&pretty=true&text=我是中国人"
测试结果如下:
[html] view
plaincopy
{
tokens: [
{
token: text
start_offset: 2
end_offset: 6
type: ENGLISH
position: 1
}
{
token: 我
start_offset: 9
end_offset: 10
type: CN_CHAR
position: 2
}
{
token: 中国人
start_offset: 11
end_offset: 14
type: CN_WORD
position: 3
}
{
token: 中国
start_offset: 11
end_offset: 13
type: CN_WORD
position: 4
}
{
token: 国人
start_offset: 12
end_offset: 14
type: CN_WORD
position: 5
}
]
}
1.create a index
2、将解压目录文件中config/ik文件夹复制到ES安装目录config文件夹下。
3、将打包得到的zip文件解压,复制elasticsearch-analysis-ik-1.6.0.jar、httpclient-4.4.1.jar、httpcore-4.4.1.jar(仓库拷贝)到ES安装目录的lib目录下。
4、在ES的plugins目录下建立ik文件夹,将打包文件中的plugin-descriptor.properties(elasticsearch-analysis-ik-master\src\main\resources)拷贝进去
重新启动elasticsearch服务,这样就完成配置了,收入命令:
[html] view
plaincopy
curl -XPOST "http://localhost:9200/userinfo/_analyze?analyzer=ik&pretty=true&text=我是中国人"
测试结果如下:
[html] view
plaincopy
{
tokens: [
{
token: text
start_offset: 2
end_offset: 6
type: ENGLISH
position: 1
}
{
token: 我
start_offset: 9
end_offset: 10
type: CN_CHAR
position: 2
}
{
token: 中国人
start_offset: 11
end_offset: 14
type: CN_WORD
position: 3
}
{
token: 中国
start_offset: 11
end_offset: 13
type: CN_WORD
position: 4
}
{
token: 国人
start_offset: 12
end_offset: 14
type: CN_WORD
position: 5
}
]
}
Quick Example
1.create a indexcurl -XPUT http://localhost:9200/index[/code]
2.create a mappingcurl -XPOST http://localhost:9200/index/fulltext/_mapping -d' { "fulltext": { "_all": { "analyzer": "ik_max_word", "search_analyzer": "ik_max_word", "term_vector": "no", "store": "false" }, "properties": { "content": { "type": "string", "store": "no", "term_vector": "with_positions_offsets", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word", "include_in_all": "true", "boost": 8 } } } }'
3.index some docscurl -XPOST http://localhost:9200/index/fulltext/1 -d' {"content":"美国留给伊拉克的是个烂摊子吗"} 'curl -XPOST http://localhost:9200/index/fulltext/2 -d' {"content":"公安部:各地校车将享最高路权"} 'curl -XPOST http://localhost:9200/index/fulltext/3 -d' {"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"} 'curl -XPOST http://localhost:9200/index/fulltext/4 -d' {"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"} '
4.query with highlightingcurl -XPOST http://localhost:9200/index/fulltext/_search -d' { "query" : { "term" : { "content" : "中国" }}, "highlight" : { "pre_tags" : ["<tag1>", "<tag2>"], "post_tags" : ["</tag1>", "</tag2>"], "fields" : { "content" : {} } } } '
相关文章推荐
- iOS中runtime的使用总结
- Git for Windows 国内下载站,发布
- 我们需要专职的QA吗?
- linux LVM 逻辑卷
- DAP in Coresight
- php代码优化及php相关问题总结
- MVC框架性能分析文章,很强!!!
- 关于 下拉框 数据 回显 的问题
- 【Python 2】文件与异常
- 【详解】Python模拟登录b站并抓取信息【教程续】
- JVM client模式和Server模式的区别
- Refresh下拉刷新
- boost shared_ptr 及C++内存管理的一些总结
- 1.7---将矩阵元素为0的行列清零0(CC150)
- 【并行计算】前缀和并行思路
- 利用zabbix监控某个目录大小
- RC电路
- android自定义标题不能填满父控件处理方式
- JVM虚拟机内存溢出
- js中的$.ajax()方法详解