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": {...}
}
}
}

最新文章

  1. ios面试技巧
  2. Vimium 下载 像个 Geek 一样去浏览
  3. Exception loading sessions from persistent storage
  4. Python编码设置
  5. 学习笔记---C++析构函数心得
  6. 自定义 textField 的清除 button
  7. PowerShell正则表达式(一) 定义模式
  8. [翻译] C++ STL容器参考手册 (总册)
  9. Tensorflow滑动平均模型tf.train.ExponentialMovingAverage解析
  10. C# 冒泡法
  11. 《图解HTTP》读书笔记(四:HTTP方法)
  12. Python——SMTP发送邮件
  13. 分析入口文件main.php
  14. Jquery学习(表单-Button)-----jQuery1.4.2
  15. 团队项目之UML图设计
  16. app判断链接参数后缀跳转不同地址
  17. 给SqlParameter参数指定或不指定:@变量标识符的区别是什么?
  18. 不要在遍历子结点时修改parent
  19. C 标准库 - string.h之strspn使用
  20. Python初学者第二天 用户输入和注释

热门文章

  1. ASP.Net MVC_DotNetZip简单使用方法,解决文件压缩的问题[转]
  2. 把之前写的几个项目放到了github上
  3. 【原】Storm及特点
  4. JSF session的用法
  5. 广州大学华软软件学院——NA视频下载
  6. BNUOJ-26475 Cookie Selection 堆,线段树等
  7. HDU-4691 Front compression 后缀数组
  8. INTERIGHT 京东自营旗舰店-京东 要把凡客给弄残啊这是。。
  9. POJ3468--A Simple Problem with Integers(Splay Tree)
  10. nyoj 129 树的判定