zoukankan      html  css  js  c++  java
  • No handler for type [text] declared on field [content]

    Install

    1.compile

    checkout ik version respective to your elasticsearch version

    git checkout tags/{version}

    mvn package

    copy and unzip target/releases/elasticsearch-analysis-ik-{version}.zip to your-es-root/plugins/ik

    2.restart elasticsearch

    Tips:

    ik_max_word: 会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合;

    ik_smart: 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”。

    Quick Example

    1.create a index

    curl -XPUT http://localhost:9200/index

    2.create a mapping

    curl -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": "text",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word",
                    "include_in_all": "true",
                    "boost": 8
                }
            }
        }
    }'

    上面这个rest请求在2.3.4版本的es服务器上会执行失败,原因是es 2.3.4上面还没有text这种类型,"type":"text" 改为 "type":"String"即可






    3.index some docs

    curl -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 highlighting

    curl -XPOST http://localhost:9200/index/fulltext/_search  -d'
    {
        "query" : { "match" : { "content" : "中国" }},
        "highlight" : {
            "pre_tags" : ["<tag1>", "<tag2>"],
            "post_tags" : ["</tag1>", "</tag2>"],
            "fields" : {
                "content" : {}
            }
        }
    }
    '
  • 相关阅读:
    1081. Rational Sum (20) -最大公约数
    在Debug模式下中断, 在Release模式下跳出当前函数的断言
    net-snmp配置文件详解
    net-snmp5.7.3移植到arm-linux平台
    NET-SNMP开发——日志输出
    SNMP常用数据操作
    40 网络相关函数(八)——live555源码阅读(四)网络
    39 网络相关函数(七)——live555源码阅读(四)网络
    38 网络相关函数(六)——live555源码阅读(四)网络
    37 网络相关函数(五)——live555源码阅读(四)网络
  • 原文地址:https://www.cnblogs.com/softidea/p/6081326.html
Copyright © 2011-2022 走看看