1、安装中文分词器IK

      下载地址:https://github.com/medcl/elasticsearch-analysis-ik

      在线下载安装: elasticsearch-plugin.bat install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.2/elasticsearch-analysis-ik-5.5.2.zip

      先下载后安装:elasticsearch-plugin.bat install file:///D:\work\ElasticSearch\plugin\elasticsearch-analysis-ik-5.5.2.zip

      

      

      

    2、重启 elasticsearch

    3、创建空索引

      curl -XPUT http://127.0.0.1:9200/index_china

      

      

      在kibana的Dev Tools中用  PUT /index_american/

      

    4、创建映射

      curl -XPOST http://127.0.0.1:9200/index_china/fulltext/_mapping -d "{\"properties\": {\"content\": {\"type\": \"text\",\"analyzer\": \"ik_max_word\",\"search_analyzer\": \"ik_max_word\"}}}"

      

      或

      POST /index_american/fulltext/_mapping

      {

        "properties":
        {
        "content": 
          {
          "type": "text",
          "analyzer": 
          "ik_max_word",
          "search_analyzer": "ik_max_word"
          }
        }
      }

      

    5、索引数据

      POST /index_china/fulltext

      {
        "content" : "中国是世界上人口最多的国家",
        "title" : "中国",
        "tags" : [ "中国", "人口" ]
      }

      

      批量索引数据

      

POST /_bulk
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "周星驰最新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "周星驰最好看的新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "周星驰最新电影,最好,新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "最最最最好的新新新新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "I'm not happy about the foxes" }

    6、查询

      

      GET /index_china/fulltext/_search
      {
      "query": {
        "match": {
            "content": "中国"
            }
          }
      }

      

      

    7、最大分词和最小分词

      ik_smart,

      ik_max_word

      

      

GET /_analyze
{
"analyzer": "ik_smart",
"text": "中华人民共和国"
}
GET /_analyze
{
"analyzer": "ik_max_word",
"text": "中华人民共和国"
}
#删除索引
DELETE /ott_test #创建索引 PUT /ott_test
{
"mappings": {
"ott_type" : {
"properties" : {
"title" : {
"type" : "text",
"index":true,
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"date" : {
"type" : "date"
},
"keyword" : {
"type" : "keyword"
},
"source" : {
"type" : "keyword"
},
"link" : {
"type" : "keyword"
}
}
}
}
} #索引数据
POST /ott_test/ott_type
{
"title":"微博新规惹争议:用户原创内容版权归属于微博?",
"link":"http://www.yidianzixun.com/article/0HHoxgVq",
"date":"2017-09-17",
"source":"虎嗅网",
"keyword":"内容"
} #分析
GET /ott_test/_analyze
{
"field": "title",
"text": "内容"
} #查询 GET /ott_test/ott_type/_search
{
"query": {
"match": {
"title": "内容"
}
}
} #只查询title和date两个字段的数据 GET /ott_test/ott_type/_search
{
"query": {"match_all": {}},
"_source": ["title","date"]
}

ElasticSearch 安装中文分词器的更多相关文章

  1. 如何给Elasticsearch安装中文分词器IK

    安装Elasticsearch安装中文分词器IK的步骤: 1. 停止elasticsearch 2.2的服务 2. 在以下地址下载对应的elasticsearch-analysis-ik插件安装包(版 ...

  2. elasticsearch安装中文分词器插件smartcn

    原文:http://blog.java1234.com/blog/articles/373.html elasticsearch安装中文分词器插件smartcn elasticsearch默认分词器比 ...

  3. ElasticSearch安装中文分词器IKAnalyzer

    # ElasticSearch安装中文分词器IKAnalyzer  本篇主要讲解如何在ElasticSearch中安装中文分词器IKAnalyzer,拆分的每个词都是我们熟知的词语,从而建立词汇与文档 ...

  4. ElasticSearch安装中文分词器IK

    1.安装IK分词器,下载对应版本的插件,elasticsearch-analysis-ik中文分词器的开发者一直进行维护的,对应着elasticsearch的版本,所以选择好自己的版本即可.IKAna ...

  5. elasticsearch安装中文分词器

    1. 分词器的安装 ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/rele ...

  6. 如何在Elasticsearch中安装中文分词器(IK)和拼音分词器?

    声明:我使用的Elasticsearch的版本是5.4.0,安装分词器前请先安装maven 一:安装maven https://github.com/apache/maven 说明: 安装maven需 ...

  7. Elasticsearch之中文分词器插件es-ik(博主推荐)

    前提 什么是倒排索引? Elasticsearch之分词器的作用 Elasticsearch之分词器的工作流程 Elasticsearch之停用词 Elasticsearch之中文分词器 Elasti ...

  8. 沉淀再出发:ElasticSearch的中文分词器ik

    沉淀再出发:ElasticSearch的中文分词器ik 一.前言   为什么要在elasticsearch中要使用ik这样的中文分词呢,那是因为es提供的分词是英文分词,对于中文的分词就做的非常不好了 ...

  9. Elasticsearch之中文分词器插件es-ik的自定义热更新词库

    不多说,直接上干货! 欢迎大家,关注微信扫码并加入我的4个微信公众号:   大数据躺过的坑      Java从入门到架构师      人工智能躺过的坑         Java全栈大联盟       ...

随机推荐

  1. [NOI2015][bzoj4197] 寿司晚宴 [状压dp+质因数]

    题面 传送门 思路 首先,要让两个人选的数字全部互质,那么有一个显然的充要条件:甲选的数字的质因数集合和乙选的数字的质因数集合没有交集 30pt 这种情况下n<=30,也就是说可用的质数只有10 ...

  2. Ubuntu安装完之后需要做的事情

    字体推荐思源 lantern可以设置全局代理 安装好了ubuntu之后,安装gnome主题 安装Gnome之前,升级系统: $ sudo apt update $ sudo apt upgrade 1 ...

  3. idea创建maven项目需要注意的问题

    idea创建maven项目之后,我从deployment中看到报部署错误的问题,下图是解决问题的办法如下图所示:

  4. Windows1小时后关机命令

    shutdown -s -t 3600 1.注销当前用户 shutdown - l 该命令只能注销本机用户,对远程计算机不适用. 2.关闭本地计算机 shutdown - s 3.重启本地计算机 sh ...

  5. Java并发(3)- 聊聊Volatile

    引言 谈到volatile关键字,大多数开发者都有一定了解,可以说是开发者非常熟悉,深入之后又非常陌生的一个关键字.相当于轻量的synchronized,也叫轻量级锁,与synchronized相比性 ...

  6. Hibernate中双向多对多的两种配置方式

    Hibernate中双向多对多的两种配置方式 1.建立多对多双向关联关系 package cn.happy.entitys; import java.util.HashSet; import java ...

  7. [ CodeVS冲杯之路 ] P1014

    不充钱,你怎么AC? 题目:http://codevs.cn/problem/1014/ 一道不用考虑价值的DP题,那么我们可以用 0 和 1 表示是否能够达到该步骤 #include<cstd ...

  8. Oracle 整理

    高效分页 select * from ( select rownum r,a from yourtable order by name ) --之所以没有把<=20放在最外面,也就是我一直用的写 ...

  9. java基础练习 17

    import java.util.Scanner; public class Seventheen { /*企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元 ...

  10. PE文件RV转FOA及FOA转RVA

    /************************************************************************/ /* 功能:虚拟内存相对地址和文件偏移的转换 参数 ...