mapping 详解4(mapping setting)
2024-08-28 22:45:55
mapping type
映射设置一般发生在:
1. 增加新的 index 的时候,添加 mapping type,对 fields 的映射进行设置
PUT twitter
{
"mappings": {
"tweet": {
"properties": {
"message": {
"type": "string"
}
}
}
}
}
2. 为 index 增加新的 mapping type,对 fields 的映射进行设置
PUT twitter/_mapping/user
{
"properties": {
"name": {
"type": "string"
}
}
}
3. 为已有 mapping type 增加新的 fields 映射设置
PUT twitter/_mapping/tweet
{
"properties": {
"user_name": {
"type": "string"
}
}
}
设置方式
1. 在 PUT 请求体中给出完整的 mapping 设置
PUT twitter
{
"mappings": { //mappings 对象,说明进行 mapping 设置
"tweet": { //指定 mapping type
"properties": { //指定 mapping type 的 properties 设置
"message": { //对字段 message 的映射进行设置
"type": "string" //mapping 参数配置
}
}
}
}
}
增加 index 的时候,除了可以设置 mapping type,还可以对 index 进行设置,比如配置自定义 analyzer、索引分片个数设置等
PUT /my_index
{
"settings": {
"analysis": {
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"my_type": {
"properties": {
"text": {
"type": "string",
"analyzer": "autocomplete"
}
}
}
}
}
2. 在 PUT 请求 URI 中指定 type,并在请求体中给出 type 的各项设置
PUT twitter/_mapping/user
{
"properties": { //指定 mapping type 的 properties 设置
"name": { //对字段 message 的映射进行设置
"type": "string" //mapping 参数配置
}
}
}
3. 一个完整的 mapping type 设置包括:Meta-fields 和 Fields 或者 properties 设置
PUT my_index
{
"mappings": {
"type_1": {
"properties": {...} //properties 设置
},
"type_2": {
"_all": { //meta-fields 设置
"enabled": false
},
"properties": {...}
}
}
}
最新文章
- ios面试技巧
- Vimium 下载 像个 Geek 一样去浏览
- Exception loading sessions from persistent storage
- Python编码设置
- 学习笔记---C++析构函数心得
- 自定义 textField 的清除 button
- PowerShell正则表达式(一) 定义模式
- [翻译] C++ STL容器参考手册 (总册)
- Tensorflow滑动平均模型tf.train.ExponentialMovingAverage解析
- C# 冒泡法
- 《图解HTTP》读书笔记(四:HTTP方法)
- Python——SMTP发送邮件
- 分析入口文件main.php
- Jquery学习(表单-Button)-----jQuery1.4.2
- 团队项目之UML图设计
- app判断链接参数后缀跳转不同地址
- 给SqlParameter参数指定或不指定:@变量标识符的区别是什么?
- 不要在遍历子结点时修改parent
- C 标准库 - string.h之strspn使用
- Python初学者第二天 用户输入和注释
热门文章
- ASP.Net MVC_DotNetZip简单使用方法,解决文件压缩的问题[转]
- 把之前写的几个项目放到了github上
- 【原】Storm及特点
- JSF session的用法
- 广州大学华软软件学院——NA视频下载
- BNUOJ-26475 Cookie Selection 堆,线段树等
- HDU-4691 Front compression 后缀数组
- INTERIGHT 京东自营旗舰店-京东 要把凡客给弄残啊这是。。
- POJ3468--A Simple Problem with Integers(Splay Tree)
- nyoj 129 树的判定