Elasticsearch 映射4
2023-03-20 14:52:22 时间
为详细的mapping属性可以参考 Mapping ,字段类型可以参考 Field datatypes
PUT mapping API
PUT /{index}/_mapping/{type}
{ body }
{index}
可以是以逗号分割的多个索引或匹配符.{type}
是类型名.{body}
中包含了准备应用的映射内容.
更新mapping
总体而言,一般情况下现有字段的mapping是不能被更新的
但以下几种情况例外:
- 新属性可以被添加到对象的数据类型区域中
- 新的多字段可以被添加到现存字段中
- 文档值可以禁用,但不能启用
- ignore_above 参数可以被更新
字段冲突
在同一个索引中,即便是在不同类型(type)下,相同名字的字段必须拥有相同的mapping,因为在内部的实现中,不同的type如果有相同字段名其实就是在使用相同的字段(基础支持)
所以说索引才是字段类型的名称空间,而类型(type)并不是
在同一索引中,除非使用 update_all_types 参数,否则在不同的type中对一个名字相同的字段进行属性更新时会抛出异常,这个操作事实上会更新这一索引中不同type里所有叫这个名字的字段属性
我的看法是,既然目前ES对一个现成的字段更新不能很好地支持,那么就不要去尝试导入数据后更新这条路,保有的数据越多,就越头疼,直接在事先规划好,设计好,通过充分的考虑根据需求进行指定,就能免去这此问题
命令汇总
uname -a
cat /etc/issue
curl 'localhost:9200/_cat/nodes?h=v'
curl -XPUT 'localhost:9200/abc/test/1?pretty' -d '{"name":"joke","age":12}'
curl 'localhost:9200/abc/test/1?pretty'
curl 'localhost:9200/abc/_mapping?pretty'
curl 'localhost:9200/abc?pretty'
curl 'localhost:9200/abc/_mapping/test/field/age?pretty'
curl 'localhost:9200/abc/_mapping/t*/field/a*?pretty'
curl 'localhost:9200/abc/_mapping/test/field/age?pretty&include_defaults=true'
curl -XPUT 'localhost:9200/abc/test/2?pretty' -d '{"name":12,"age":23}'
curl 'localhost:9200/abc/test/2?pretty'
curl 'localhost:9200/abc/_mapping/t*/field/n*?pretty'
curl -XPUT 'localhost:9200/abc/test/3?pretty' -d '{"name":"testtype","age":"lili"}'
curl 'localhost:9200/abc/test/3?pretty'
curl -XPUT 'localhost:9200/abc/_mapping/test?update_all_types&pretty' -d '{"properties" : {"age" : {"type" : "string"}}}'
curl 'localhost:9200/abc/_mapping/test/field/age?pretty'
curl -XPUT 'localhost:9200/def?pretty' -d '{"mappings": {"test": {"properties": {"userid": {"type": "integer"}}}}}'
curl 'localhost:9200/def/_mapping?pretty'
curl -XPUT 'localhost:9200/def/_mapping/test?pretty' -d '{"properties": {"city": {"type": "string"}}}'
curl 'localhost:9200/def/_mapping?pretty'
原文地址
相关文章
- 从本体论开始说起——运营商关系图谱的构建及应用
- 如何成为一名数据科学家?
- 从未见过的堂兄杀了人,你的DNA是关键证据
- 20个安全可靠的免费数据源,各领域数据任你挑
- 20个安全可靠的免费数据源,各领域数据任你挑
- 阿里云李飞飞:All in Cloud时代,云原生数据库优势明显
- 基于Hadoop生态系统的一高性能数据存储格式CarbonData(性能篇)
- 大数据告诉你:10年漫威,到底有多少角色
- TigerGraph:实时图数据库助力金融风控升级
- Splunk利用Splunk Connected Experiences和Splunk Business Flow 扩大数据访问
- 大数据开发常见的9种数据分析手段
- 以免在景区看人,我爬了5W条全国景点门票数据...
- 【实战解析】基于HBase的大数据存储在京东的应用场景
- 数据科学家告诉你哪些计算机科学书籍是你应该看的
- Kafka作为大数据的核心技术,你了解多少?
- Spring Boot 整合 Redis 实现缓存操作
- 大数据学习必须掌握的五大核心技术有哪些?
- 基于Antlr在Apache Flink中实现监控规则DSL化的探索实践
- 甲骨文再次被Gartner评为分析型数据管理解决方案魔力象限领导者
- 爬取吴亦凡微博102118条转发数据,扒一扒流量的真假