elasticsearch安装ik分词

1.下载地址

ik分词地址

2.查询

查询安装的分词

curl localhost:9200/_cat/plugins 

测试ik分词

http://localhost:9200/_analyze?analyzer=ik_smart&text=无花果支付宝

3.使用

查询已有索引

curl localhost:9200/_cat/indices?v 

创建索引

curl -XPUT localhost:9200/knowledge

创建映射

curl -XPOST localhost:9022/konwledge/student/_mapping -d "{"student":{"properties":{"name":{"type":"text","analyzer":"ik_max_word","search_analyzer":"ik_smart"},"age":{"type": "long"}}}}"

4. ik和pinyin分词

拼音分词下载

4.1 setting设置
curl -XPUT "http://localhost:9200/medcl/" -d'
{
    "index": {
        "analysis": {
            "analyzer": {
                "default": {
                    "tokenizer": "ik_max_word"
                },
                "pinyin_analyzer": {
                    "tokenizer": "shopmall_pinyin"
                }
            },
            "tokenizer": {
                "shopmall_pinyin": {
                    "keep_joined_full_pinyin": "true",
                    "keep_first_letter": "true",
                    "keep_separate_first_letter": "false",
                    "lowercase": "true",
                    "type": "pinyin",
                    "limit_first_letter_length": "16",
                    "keep_original": "true",
                    "keep_full_pinyin": "true"
                }
            }
        }
    }
}'
4.2 创建mapping
curl -XPOST http://localhost:9200/medcl/folks/_mapping -d'
{
    "folks": {
        "properties": {
            "name": {
                "type": "text",
                "analyzer": "ik_max_word",
                "include_in_all": true,
                "fields": {
                    "pinyin": {
                        "type": "text",
                        "analyzer": "pinyin_analyzer"
                    }
                }
            }
        }
    }
}'

拼音分词效果:

http://localhost:9200/medcl/folks/_search?q=name.pinyin:zhrmghg

中文分词测试:

curl -XPOST "http://localhost:9200/medcl/folks/_search?q=name:刘德"

转载于:https://www.cnblogs.com/bob-coder/p/11569922.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值