码迷,mamicode.com
首页 > 其他好文 > 详细

No handler for type [text] declared on field [content]

时间:2016-11-19 20:38:43      阅读:1001      评论:0      收藏:0      [点我收藏+]

标签:plugins   zip   compile   create   组合   src   服务   als   analyzer   

 

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" : {}
        }
    }
}

 

No handler for type [text] declared on field [content]

标签:plugins   zip   compile   create   组合   src   服务   als   analyzer   

原文地址:http://www.cnblogs.com/softidea/p/6081326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!