<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # _parent field 原文鏈接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.3/mapping-parent-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/mapping-parent-field.html) 譯文鏈接 : [http://www.apache.wiki/display/Elasticsearch/_parent+field](http://www.apache.wiki/display/Elasticsearch/_parent+field) 貢獻者 : [朱彥安](/display/~zhuyanan),[ApacheCN](/display/~apachecn),[Apache中文網](/display/~apachechina) 通過使一個映射類型成為另一個映射類型的父類,可以在同一索引中的文檔之間建立父子關系 :? ``` curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "my_parent": {}, "my_child": { "_parent": { "type": "my_parent" # 1 } } } } ' curl -XPUT 'localhost:9200/my_index/my_parent/1?pretty' -H 'Content-Type: application/json' -d' # 2 { "text": "This is a parent document" } ' curl -XPUT 'localhost:9200/my_index/my_child/2?parent=1&pretty' -H 'Content-Type: application/json' -d' # 2 { "text": "This is a child document" } ' curl -XPUT 'localhost:9200/my_index/my_child/3?parent=1&refresh=true&pretty' -H 'Content-Type: application/json' -d' # 4 { "text": "This is another child document" } ' curl -XGET 'localhost:9200/my_index/my_parent/_search?pretty' -H 'Content-Type: application/json' -d' { "query": { "has_child": { # 5 "type": "my_child", "query": { "match": { "text": "child document" } } } } } ' ``` | 1 | 該 **my_parent** 類型是 **my_child** 類型的 **parent**(父節)。 | | 2 | 索引 **parent** 文檔。 | | 3?4 | 索引兩個子文檔,指定父文檔的 **ID**。 | | 5 | 查找具有與查詢匹配的子項的所有父文檔。 | 有關更多信息,請參閱 **[has_child](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-has-child-query.html)**??和 **[has_parent](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-has-parent-query.html)?**查詢,**[children aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-aggregations-bucket-children-aggregation.html) **和 **[inner hits](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-request-inner-hits.html#parent-child-inner-hits)?**。 ?該 **_parent**?字段的值可以在 **aggregations**(聚合)和 **scripts**(腳本)中訪問,并且可以使用?**[parent_id](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-parent-id-query.html)?**查詢進行查詢 :? ``` curl -XGET 'localhost:9200/my_index/_search?pretty' -H 'Content-Type: application/json' -d' { "query": { "parent_id": { "type": "my_child", "id": "1" } }, "aggs": { "parents": { "terms": { "field": "_parent", "size": 10 } } }, "script_fields": { "parent": { "script": { "inline": "doc[\u0027_parent\u0027]" } } } } ' ``` | 1 | 查詢 **_parent** 字段的 **id**(參考 **[has_parent](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-has-parent-query.html)** 查詢和 [**has_child**?](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-has-child-query.html)查詢) | | 2 | 在 **_parent** 字段上的聚合(參考 **[children aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-aggregations-bucket-children-aggregation.html)**) | | 3 | 在腳本中訪問 **_parent** 字段 | ### Parent-child restrictionsedit (父子限制) * 父類和子類型必須不同 - 不能在相同類型的文檔之間建立父子關系。 * 該 **_parent.type**?設置只能指向不存在的類型。 這意味著類型在創建后不能成為父類型。 * 父文檔和子文檔必須在相同的分片上索引。 父 **ID** 用作子節點的路由值,以確保子節點與父節點在同一分片上進行索引。 這意味著在獲取,刪除或更新子文檔時需要提供相同的 **parent** 值。 ### Global ordinals (全局序列) 父子使用?**[全局序列](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/fielddata.html#global-ordinals)?**來加快連接。 在對分片進行任何更改之后,需要重建全局序列。 分片中存儲的父 **ID** 值越多,重建?**_parent?**字段的全局序列所需的時間越長。 默認情況下,全局序列是高效的:如果索引已更改,則?**_parent?**字段的全局序列將作為刷新的一部分進行重新構建。 這會增加刷新時間。 然而,大多數時候,這是正確的選擇,否則,當使用第一個?**parent-child query**(父子查詢)或 **aggregation**(聚合)時,全局序列將被重建。 這可能會為您的用戶帶來較大的延遲,并且通常會更糟,因為在發生許多寫入時,可能會在單個刷新間隔內重新創建?**_parent?**字段的多個全局序列。 當?**parent/child**?不頻繁使用時,寫入頻繁發生,最好禁用預加載 :? ``` curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "my_parent": {}, "my_child": { "_parent": { "type": "my_parent", "eager_global_ordinals": false } } } } ' ``` 可以檢查全局序列使用的堆數量,如下所示 :? ``` # Per-index curl -XGET 'localhost:9200/_stats/fielddata?human&fields=_parent&pretty' # Per-node per-index curl -XGET 'localhost:9200/_nodes/stats/indices/fielddata?human&fields=_parent&pretty' ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看