索引库操作

1.mapping映射属性

1.1什么是mapping

2.创建索引库

3.查看索引库

4.删除索引库

5.修改索引库名


1.mapping映射属性

1.1什么是mapping

mapping是对索引库中文档的约束,对应MySQL中的表的概念,常见的mapping属性包括:

  • type:字段数据类型,常见的简单类型有:
  • 字符串:text(可分词的文本)、keyword(精确值,例如:品牌、国家、ip地址)
  • 数值:long、integer、short、byte、double、float、
  • 布尔:boolean
  • 日期:date
  • 对象:object
  • index:是否创建索引,默认为true
  • analyzer:使用哪种分词器
  • properties:该字段的子字段

2.创建索引库

3.查看索引库

GET /索引库名

4.删除索引库

DELETE /索引库名

5.修改索引库名

索引库和mapping一旦创建无法修改,但是可以添加新的字段,语法如下:

PUT /索引库名/_mapping

{

"properties": {

"新字段名":{

"type": "integer"

}

}

}

示例:

PUT /my_index/_mapping

{

"properties": {

"title": {

"type": "text",

"fields": {

"keyword": {

"type": "keyword",

"ignore_above": 256

}

}

}

}

}

相关推荐
for_ever_love__1 小时前
Objective-C学习 NSSet 和 NSMutableSet 功能详解
开发语言·学习·ios·objective-c
云原生指北3 小时前
GitHub Copilot SDK 入门:五分钟构建你的第一个 AI Agent
java
似水明俊德7 小时前
02-C#.Net-反射-面试题
开发语言·面试·职场和发展·c#·.net
Leinwin7 小时前
OpenClaw 多 Agent 协作框架的并发限制与企业化规避方案痛点直击
java·运维·数据库
薛定谔的悦7 小时前
MQTT通信协议业务层实现的完整开发流程
java·后端·mqtt·struts
enjoy嚣士8 小时前
springboot之Exel工具类
java·spring boot·后端·easyexcel·excel工具类
Thera7778 小时前
C++ 高性能时间轮定时器:从单例设计到 Linux timerfd 深度优化
linux·开发语言·c++
罗超驿8 小时前
独立实现双向链表_LinkedList
java·数据结构·链表·linkedlist
炘爚9 小时前
C语言(文件操作)
c语言·开发语言
阿蒙Amon9 小时前
C#常用类库-详解SerialPort
开发语言·c#