栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Elasticsearch索引知多少

Elasticsearch索引知多少

Elasticsearch 基本操作 1.索引的增删改查
  • 查看集群健康
GET     /_cluster/health
  • 创建索引
PUT     /index_test

例如:

{
    "settings": {
        "index": {
            "number_of_shards": "2",
            "number_of_replicas": "0"
        }
    }
}
  • 查看索引
GET     _cat/indices?v
  • 删除索引
DELETE      /index_test
2.索引的mappings映射
  1. 索引分词概念
    index:默认true,设置为false的话,那么这个字段就不会被索引
  2. 创建索引同时创建mappings
PUT     /index_mapping

例如:

{
    "mappings": {
        "properties": {
            "realname": {
            	"type": "text",
            	"index": true
            },
            "username": {
            	"type": "keyword",
            	"index": false
            }
        }
    }
}

  1. 查看分词效果
GET         /index_mapping/_analyze
参数:
{
	"field": "realname",
	"text": "chocolate is good"
}

注:如果type是keyword,则不会被分词

  1. 尝试修改
POST        /index_mapping/_mapping
参数:
{
    "properties": {
        "name": {
        	   "type": "long"
        }
    }
}

已创建的属性不可以更改,只能进行添加

  1. 为已存在的索引创建mappings
POST        /index_mapping/_mapping
参数:
{
    "properties": {
        "id": {
        	"type": "long"
        },
        "age": {
        	"type": "integer"
        }
  }

3.主要数据类型
  • text, keyword, string
  • long, integer, short, byte
  • double, float
  • boolean
  • date
  • object
  • 数组不能混,类型一致
4.字符串
  • text:文字类需要被分词被倒排索引的内容,比如商品名称,商品详情,商品介绍,使用text。
  • keyword:不会被分词,不会被倒排索引,直接匹配搜索,比如订单状态,用户qq,微信号,手机号等,这些精确匹配,无需分词。
以上是关于数据库及表结构的介绍,下篇文章将介绍表数据的相关操作
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/688371.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号