zoukankan      html  css  js  c++  java
  • elastic-search单机部署以及中文分词IKAnalyzer安装

    前提条件

    elasticsearch使用版本5.6.3,需要jdk版本1.8,低于该版本不能使用

    下载

    https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.zip

    启动

    1、进入目录C: esteselasticsearch-5.6.3in

    2、点击elasticsearch.bat即可启动

    验证

    中文分词安装

    1、进入目录C: esteselasticsearch-5.6.3in

    2、执行命令elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.3/elasticsearch-analysis-ik-5.6.3.zip

    中文分词验证

    1、创建分词索引库

    curl -PUT http://localhost:9200/fenci_1/
    {
      "mappings": {
        "mynames": {
           "properties": {
                "content": {
                    "type": "text",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"
                }
            }
        }
      }
    } 

    2、搜索切词验证

    ik_max_word

    http://192.168.4.131:9201/fenci_1/_analyze?text=中华人民共和国MN&tokenizer=ik_max_word

    ik_smart

    http://localhost:9200/fenci_1/_analyze?text=中华人民共和国MN&tokenizer=ik_smart

    3、添加索引数据

    curl -XPOST http://localhost:9200/fenci_1/mynames/1 -d'
    {"content":"美国留给伊拉克的是个烂摊子吗"}
    '
    curl -XPOST http://localhost:9200/fenci_1/mynames/2 -d'
    {"content":"公安部:各地校车将享最高路权"}
    '
    curl -XPOST http://localhost:9200/fenci_1/mynames/3 -d'
    {"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
    '
    curl -XPOST http://localhost:9200/fenci_1/mynames/4 -d'
    {"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
    '
    

    4、搜索

    curl -XPOST http://localhost:9200/fenci_1/mynames/_search  -d'
    {
        "query" : { "match" : { "content" : "中国" }}
    }
    

      

  • 相关阅读:
    入侵特斯拉——智能汽车安全性分析
    D-Link系列路由器漏洞挖掘入门
    工控安全入门之 Ethernet/IP
    浅谈JS数据类型存储问题
    【备忘】12306购票必杀技
    制作炫酷的专题页面
    杂记(下)
    杂记(上)
    跨域请求解决方案
    好用的表单验证插件
  • 原文地址:https://www.cnblogs.com/lilei2blog/p/7799210.html
Copyright © 2011-2022 走看看