【问题标题】:ElasticSearch 7 & PHP - Create mapping for parent / child relationElasticSearch 7 & PHP - 为父/子关系创建映射
【发布时间】:2021-02-01 18:19:03
【问题描述】:

我想在我的索引中索引buildings 2 种类型的文档:buildingapartment

一个building可以有多个apartment,所以我想使用父子关系。

我使用 ES 7.10 和 PHP 以及官方 PHP 库(elasticsearch/elasticsearch)。

根据文档 (https://www.elastic.co/guide/en/elasticsearch/guide/current/parent-child-mapping.html),我必须使用类似:

PUT index buildings
{
  "mappings": {
    "building": {},
    "apartment": {
      "_parent": {
        "type": "building"
      }
    }
  }
}

在我的 PHP 中有:

$this->getClient()->indices()
        ->create([
            'index' => 'buildings',
            'body' => [
                'mappings' => [
                    'building' => [],
                    'apartment' => [
                        '_parent' => [
                            'type' => 'building'
                        ]
                    ]
                ]
            ]
        ]);

哪个会引发错误:

根映射定义包含不受支持的参数:[apartment: {_parent={type=building}}] [building: []]"}},"status":400}

我错过了什么吗?

【问题讨论】:

    标签: php elasticsearch


    【解决方案1】:

    据我记得,在 Elasticsearch 7 中,父/类型已被弃用,而支持 join 类型,因此这可能是您收到异常的原因。

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

    【讨论】:

    • 哦,是的...我正在阅读一个旧文档,我没有注意到警告,我会检查这个新文档,谢谢
    猜你喜欢
    • 1970-01-01
    • 2013-05-26
    • 2022-01-22
    • 2017-08-29
    • 2019-09-27
    • 1970-01-01
    • 2021-03-23
    • 2011-01-31
    • 1970-01-01
    相关资源
    最近更新 更多