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

      

  • 相关阅读:
    Simple DirectMedia Layer常用API总结
    [游戏复刻] Super Mario Brothers(1985. Famicom)
    [游戏复刻] 2048(2014. Android)
    图的结构以及寻路算法的c实现
    散列查找的C实现
    【游戏编程从0开始】一、基本结构
    C++中const关键字用法总结
    C标准库常用函数概要
    字符串表达式计算器的设计
    初探数据结构
  • 原文地址:https://www.cnblogs.com/linlf03/p/12775287.html
Copyright © 2011-2022 走看看