<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Rollover Index/滾動索引 原文鏈接 : [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html) 譯文鏈接 : [Rollover Index/滾動索引](/pages/viewpage.action?pageId=4882801) 貢獻者 : [Le-Mon](/display/~tanwen) 當現有索引被認為太大或太舊時,滾動索引API會將別名滾動到新的索引。 API接受單個別名和條件列表。 別名只能指向一個索引。 如果索引滿足指定的條件,則創建一個新的索引,并將別名切換到指向新的索引。 ``` curl -XPUT 'localhost:9200/logs-000001 ?pretty' -d' { "aliases": { "logs_write": {} } }' # Add > 1000 documents to logs-000001 curl -XPOST 'localhost:9200/logs_write/_rollover ?pretty' -d' { "conditions": { "max_age": "7d", "max_docs": 1000 } }' ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html#CO122-1) | 創建索引?`logs-0000001`?別名為?`logs_write`. | | [![](https://img.kancloud.cn/50/46/50466ab92768bfee2306a5da100c7496_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html#CO122-2) | 如果 ogs_write 指向的索引是在7天以前創建的,或者包含1000個以上的文檔,則會創建 logs-000002索引,并更新logs_write別名以指向logs-000002. | 上述可能會返回如下的響應: ``` { "acknowledged": true, "shards_acknowledged": true, "old_index": "logs-000001", "new_index": "logs-000002", "rolled_over": true, "dry_run": false, "conditions": { "[max_age: 7d]": false, "[max_docs: 1000]": true } } ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html#CO123-1) | index 是否被滾動. | | [![](https://img.kancloud.cn/50/46/50466ab92768bfee2306a5da100c7496_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html#CO123-2) | Whether the rollover was dry run. | | [![](https://img.kancloud.cn/59/09/59090687855ebb833c063fe09e622609_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html#CO123-3) | 條件的列表. | ## Naming the new index/新索引名稱 如果現有索引的名稱以 - 和數字結尾。 logs-000001 - 然后新索引的名稱將遵循相同的模式,增加數字(logs-000002)。 無論舊索引名稱如何,編號為零填充長度為6。 如果舊名稱與此模式不匹配,則必須按照如下所示,指定新索引的名稱: ``` curl -XPOST 'localhost:9200/my_alias/_rollover/my_new_index_name?pretty' -d' { "conditions": { "max_age": "7d", "max_docs": 1000 } }' ``` ## Using date math with the rolllover API/使用滾動API的日期計算 使用[日期計算](https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html "Date math support in index names"): 根據索引滾動的日期來命名滾動索引是有用的技術,例如 ?`logstash-2016.02.03`.。 滾動API支持日期,但要求索引名稱以一個破折號后跟一個數字,例如 logstash-2016.02.03-1,每次索引滾動時都會增加。 例如 ``` # PUT /<logs-{now/d}-1> with URI encoding: curl -XPUT 'localhost:9200/%3Clogs-%7Bnow%2Fd%7D-1%3E ?pretty' -d' { "aliases": { "logs_write": {} } }' curl -XPUT 'localhost:9200/logs_write/log/1?pretty' -d' { "message": "a dummy log" }' # Wait for a day to pass curl -XPOST 'localhost:9200/logs_write/_rollover ?pretty' -d' { "conditions": { "max_docs": "1" } }' ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html#CO124-1) | `創建當日的索引 logs-2016.10.31-1` | | [![](https://img.kancloud.cn/50/46/50466ab92768bfee2306a5da100c7496_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html#CO124-2) | 當日索引滾動, 立即生成如.?`logs-2016.10.31-000002`?, 或者 `logs-2016.11.01-000002`?24小時后 | 然后可以按照?[日期數學文檔](https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html "Date math support in index names")?中的描述來引用這些索引。 例如,要搜索過去三天創建的索引,您可以執行以下操作: ``` # GET /<logs-{now/d}-*>,<logs-{now/d-1d}-*>,<logs-{now/d-2d}-*>/_search curl -XGET 'localhost:9200/%3Clogs-%7Bnow%2Fd%7D-*%3E%2C%3Clogs-%7Bnow%2Fd-1d%7D-*%3E%2C%3Clogs-%7Bnow%2Fd-2d%7D-*%3E/_search?pretty' ``` ## Defining the new index/定義新索引 ?新索引的設置,映射和別名取自任何匹配的[索引模板](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html "Index Templates")。 此外,您可以在請求正文中指定設置,映射和別名,就像?[create index](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html "Create Index")? API一樣。 請求中指定的值覆蓋匹配索引模板中設置的任何值。 例如,以下滾動請求將覆蓋index.number_of_shardssetting: ``` curl -XPUT 'localhost:9200/logs-000001?pretty' -d' { "aliases": { "logs_write": {} } }' curl -XPOST 'localhost:9200/logs_write/_rollover?pretty' -d' { "conditions" : { "max_age": "7d", "max_docs": 1000 }, "settings": { "index.number_of_shards": 2 } }' ``` ## Dry run/干運行 滾動API支持dry_run模式,可以在不執行實際滾動的情況下檢查請求條件: ``` curl -XPUT 'localhost:9200/logs-000001?pretty' -d' { "aliases": { "logs_write": {} } }' curl -XPOST 'localhost:9200/logs_write/_rollover?dry_run&pretty' -d' { "conditions" : { "max_age": "7d", "max_docs": 1000 } }' ``` ## Wait For Active Shards/等待激活分片 因為滾動操作會創建一個新的索引,因此在創建索引時的wait_for_active_shards 設置也適用于滾動操作。
                  <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>

                              哎呀哎呀视频在线观看