zoukankan      html  css  js  c++  java
  • 关于IK 分词器

    准备:

    1 创建索引:

    PUT my_index
    PUT my_index2

    2 先做好映射:
    PUT /my_index/*/_mapping
    {
    "properties": {
    "addTime": {
    "type": "date",
    "format": "strict_date_optional_time||epoch_millis"
    },
    "content": {
    "type": "string",
    "analyzer": "ik"
    },
    "creatorId": {
    "type": "long"
    },
    "fileName": {
    "type": "string",
    "analyzer": "ik"
    },
    "filePath": {
    "type": "string",
    "index": "not_analyzed"
    },
    "id": {
    "type": "long"
    },
    "lastModified": {
    "type": "long"
    },
    "revisionCount": {
    "type": "long"
    },
    "size": {
    "type": "long"
    }
    }
    }

    3 准备数据:
    PUT /my_index2/aa/1
    {
    "fileName": "中华人民共和国",
    "content": "从重新开始hello jetty"
    }

    PUT /my_index/aa/1
    {
    "fileName": "中华人民共和国",
    "content": "从重新开始hello jetty"
    }

    GET /my_index2/_mapping

    测试:
    GET /my_index/aa/_search
    {
    "query": {
    "term": {
    "fileName": "人民"
    }
    }
    }

    GET /my_index2/aa/_search
    {
    "query": {
    "term": {
    "fileName": "人民"
    }
    }
    }

    说明:

    通过下面的是测试不出来的, 因为, 她已经制定了分词器为 ik,

    POST /my_index/_analyze?pretty=true
    {
    "text": "我是中国人"
    }

    使用query查询的时候, 查询器必须是 term, 如果是match, 查询结果是一样的。

  • 相关阅读:
    淘女郎相册爬虫(Python编写)
    在 Linux 命令行中使用和执行 PHP 代码
    PHP PhantomJs中文文档(翻译)
    PHP
    PHP
    PHP
    PHP — 用PHP实现一个双向队列
    Redis — CentOS6.4安装Redis以及安装PHP客户端phpredis
    Linux
    Memcache学习笔记
  • 原文地址:https://www.cnblogs.com/FlyAway2013/p/5981019.html
Copyright © 2011-2022 走看看