分给线一下内容为理解错误内容,实际允许建立父子分档,只是类型改成来 join

官方demo:

join datatypeedit
The join datatype is a special field that creates parent/child relation within documents of the same index. The relations section defines a set of possible relations within the documents, each relation being a parent name and a child name. A parent/child relation can be defined as follows: PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"my_join_field": {
"type": "join",
"relations": {
"question": "answer"
}
}
}
}
}
}

链接:https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html

=========================分割线========================

用到了6.2,还以为像5.X 一样允许建立 父-子关系文档 ,即一个索引下允许映射多个类型,操作后发现行不通

如下代码:

PUT /company
{
"mappings": {
"branch": {},
"employee": {
"_parent": {
"type": "branch"
}
}
}
}

找到最新的官方文档,给出了说明,大意是:

6.0.0移除了一个索引允许映射多个类型,虽然还支持同索引多类型查询,但是Elasticsearch 7.0.0的版本将完全放弃。

不过官方给了另外的方案解决

Custom type fieldedit
Of course, there is a limit to how many primary shards can exist in a cluster so you may not want to waste an entire shard for a collection of only a few thousand documents. In this case, you can implement your own custom type field which will work in a similar way to the old _type. Let’s take the user/tweet example above. Originally, the workflow would have looked something like this: PUT twitter
{
"mappings": {
"user": {
"properties": {
"name": { "type": "text" },
"user_name": { "type": "keyword" },
"email": { "type": "keyword" }
}
},
"tweet": {
"properties": {
"content": { "type": "text" },
"user_name": { "type": "keyword" },
"tweeted_at": { "type": "date" }
}
}
}
} PUT twitter/user/kimchy
{
"name": "Shay Banon",
"user_name": "kimchy",
"email": "shay@kimchy.com"
} PUT twitter/tweet/1
{
"user_name": "kimchy",
"tweeted_at": "2017-10-24T09:00:00Z",
"content": "Types are going away"
} GET twitter/tweet/_search
{
"query": {
"match": {
"user_name": "kimchy"
}
}
}
You could achieve the same thing by adding a custom type field as follows: PUT twitter
{
"mappings": {
"_doc": {
"properties": {
"type": { "type": "keyword" },
"name": { "type": "text" },
"user_name": { "type": "keyword" },
"email": { "type": "keyword" },
"content": { "type": "text" },
"tweeted_at": { "type": "date" }
}
}
}
} PUT twitter/_doc/user-kimchy
{
"type": "user",
"name": "Shay Banon",
"user_name": "kimchy",
"email": "shay@kimchy.com"
} PUT twitter/_doc/tweet-1
{
"type": "tweet",
"user_name": "kimchy",
"tweeted_at": "2017-10-24T09:00:00Z",
"content": "Types are going away"
} GET twitter/_search
{
"query": {
"bool": {
"must": {
"match": {
"user_name": "kimchy"
}
},
"filter": {
"match": {
"type": "tweet"
}
}
}
}
} The explicit type field takes the place of the implicit _type field.

  这是官网的6.x的关于此点的描述:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

elasticsearch 6.0.0及之后移除了一个索引允许映射多个类型的操作(Removal of mapping types)的更多相关文章

  1. Elasticsearch 7.4.0官方文档操作

    官方文档地址 https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html 1.0.0 设置Elasticsea ...

  2. ElasticSearch入门系列(三)文档,索引,搜索和聚合

    一.文档 在实际使用中的对象往往拥有复杂的数据结构 Elasticsearch是面向文档的,这意味着他可以存储整个对象或文档,然而他不仅仅是存储,还会索引每个文档的内容使之可以被搜索,在Elastic ...

  3. ELK——安装 logstash 2.2.0、elasticsearch 2.2.0 和 Kibana 3.0

    本文内容 Elasticsearch logstash Kibana 参考资料 本文介绍安装 logstash 2.2.0 和 elasticsearch 2.2.0,操作系统环境版本是 CentOS ...

  4. elasticSearch(5.3.0)的评分机制的研究

    1.  ElasticSearch的评分 在用ElasticSearch作为搜索引擎的时候,如果采用关键字进行查询,ElasticSearch会对每个符合查询条件的文档进行评分,在5.3.0的版本中, ...

  5. ElasticSearch 5.0.0 集群安装部署文档

    1.  搭建环境 3台物理机 操作系统 centos7 es1   192.168.31.141   4g内存   2核 es2   192.168.31.142   4g内存   2核 es3    ...

  6. Elasticsearch学习之ElasticSearch 5.0.0 安装部署常见错误或问题

    ElasticSearch 5.0.0 安装部署常见错误或问题 问题一: [--06T16::,][WARN ][o.e.b.JNANatives ] unable to install syscal ...

  7. ElasticSearch(六) Elasticsearch在Thinkphp5.0中的使用

    首先下载需要引入的类库 链接:https://pan.baidu.com/s/1XEXviLoWM-ypwJ_B0jXqlg 密码:u54t //Elasticsearch.zip类库压缩包地址 然后 ...

  8. Elasticsearch使用java读取数据报错NoNodeAvailableException: None of the configured nodes are available: [127.0.0.1:9300]

    对于这个问题,大部分人出现在这个地方: Client client = new TransportClient(settings).addTransportAddress(new InetSocket ...

  9. 【拆分版】Docker-compose构建Elasticsearch 7.1.0集群

    写在前边 搞了两三天了,一直有个问题困扰着我,ES集群中配置怎么能正确映射到主机上,这边经常报ClusterFormationFailureHelper master not discovered o ...

随机推荐

  1. scrapy 6023 telnet查看爬虫引擎相关状态

    Telnet终端(Telnet Console) Scrapy提供了内置的telnet终端,以供检查,控制Scrapy运行的进程. telnet仅仅是一个运行在Scrapy进程中的普通python终端 ...

  2. Quartz教程五:SimpleTrigger

    原文链接 | 译文链接 | 翻译:nkcoder 本系列教程由quartz-2.2.x官方文档翻译.整理而来,希望给同样对quartz感兴趣的朋友一些参考和帮助,有任何不当或错误之处,欢迎指正:有兴趣 ...

  3. C++复习14 构造函数初始化调用顺序

    1.关于构造函数初始化调用顺序的问题. 首先是父类和子类的,首先调用父类的构造函数,然后调用子类的构造函数.但是对于子类中有其他类型的数据成员的时候,会在调用该类的构造函数之前,调用其数据成员的构造函 ...

  4. MySQL小误区:关于set global sql_slave_skip_counter=N 命令的一些点

    背景知识1:     在主从库维护中,有时候需要跳过某个无法执行的命令,需要在slave处于stop状态下,执行 set global sql_slave_skip_counter=N以跳过命令.常用 ...

  5. C++设计模式之-建造者模式

    建造者模式的定义将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示(DP).<大话设计模式>举了一个很好的例子——建造小人,一共需建造6个部分,头部.身体.左右手.左 ...

  6. this指针逃逸问题

    this指针逃逸是指在构造函数返回之前,其他线程已经就持有了该对象的应用,产生的结果自然和预期可能会产生差异.常见的this指针逃逸,在并发编程实战一书中,作者指出:在构造函数中注册事件监听,在构造函 ...

  7. vim+ctags用法

    vim用法     在VIM编辑器的环境下用":make"就可以编译程序,如果程序中有错误,就会显示出来.          下列命令可以快速定位,并修改错误错误 ":c ...

  8. L157

    UK Watchdog: Smugglers to Exploit Border if no Brexit DealSmugglers and other organized criminals ar ...

  9. The program environment for cypress cy8ckit-002

    customer use cypress ic to make sure the  wireless products, we are prepare to establish the environ ...

  10. 初识jQuery(2)

    1.DOM模型 1.1以对象描述文档的方式就是DOM 节点对象就是被称为DOM对象(标签对象) 1.2节点 元素节点(标签) 文本节点(标签内容) 属性节点(标签属性) 2.Jquery语法结构 $( ...