zoukankan      html  css  js  c++  java
  • ElasticSearch mapping(类似于数据库表中的各个字段定义)

    1、创建索引,定义mappings属性。

    类型为keyword是不会被分词的。

    index: 默认为true,设置为false,那么这个字段就不会被索引

     创建好后,在http://localhost:9100/  中查看索引的信息

    2、查看分词效果

     返回如下:

    {
        "tokens": [
            {
                "token": "nick",
                "start_offset": 0,
                "end_offset": 4,
                "type": "<ALPHANUM>",
                "position": 0
            },
            {
                "token": "is",
                "start_offset": 5,
                "end_offset": 7,
                "type": "<ALPHANUM>",
                "position": 1
            },
            {
                "token": "a",
                "start_offset": 8,
                "end_offset": 9,
                "type": "<ALPHANUM>",
                "position": 2
            },
            {
                "token": "good",
                "start_offset": 10,
                "end_offset": 14,
                "type": "<ALPHANUM>",
                "position": 3
            },
            {
                "token": "man",
                "start_offset": 15,
                "end_offset": 18,
                "type": "<ALPHANUM>",
                "position": 4
            }
        ]
    }
    

      

    3、增加索引的属性

    增加id和age属性。默认是不能修改属性的,要先删除,在增加。

     属性类型可以为以下几种

    "properties": {
    "birthday": {
    "type": "date"
    },
    "score": {
    "type": "float"
    },
    "sex": {
    "type": "byte"
    },
    "is_teenger": {
    "type": "boolean"
    },
    "id": {
    "type": "long"
    },
    "relationship": {
    "type": "object"
    },
    "money2": {
    "type": "float"
    },
    "age": {
    "type": "integer"
    },
    "money1": {
    "type": "double"
    },
    "realname": {
    "type": "text"
    },
    "username": {
    "index": false,
    "type": "keyword"
    }
    

      

  • 相关阅读:
    centos 搭建 sftp 服务器
    apt-get 安装时,提示lock被占用
    Kafka
    设计模式-分类
    SparkSQL – 从0到1认识Catalyst
    Spark分布式计算引擎
    Spark存储管理
    Spart RDD
    硬件工程师的你也不想一辈子画图、调板子吧!!!
    如何理解IPD+CMMI+Scrum一体化研发管理解决方案之Scrum篇
  • 原文地址:https://www.cnblogs.com/linlf03/p/12775287.html
Copyright © 2011-2022 走看看