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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Create Index /創建索引 原文鏈接 : [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html) 譯文鏈接 : [Create Index /創建索引](/pages/viewpage.action?pageId=4882789) 貢獻者 : [Le-Mon](/display/~tanwen) 注意:涉及翻譯內容: Index-索引;types-類型;mapping-映射;aliases-別名;shards-分片;replicas-副本 創建索引(index API)允許實例化一個索引。Elasticsearch提供支持多種索引,包括跨多個索引執行操作。 ## Index Settings/索引設置 每個索引創建的時候可以包含與之關聯的特定設置。 ``` ?curl -XPUT 'localhost:9200/twitter?pretty' -d' { "settings" : { "index" : { "number_of_shards" : 3, "number_of_replicas" : 2 } } }' ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#CO119-1) | ?默認 `number_of_shards`?為 5 | | [![](https://img.kancloud.cn/50/46/50466ab92768bfee2306a5da100c7496_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#CO119-2) | 默認?`number_of_replicas`?為 1 (對于主 shard 只有一個副本) | 上述 curl 命令創建了一個 twitter 索引,可以通過?[YAML](http://www.yaml.org/)?或者?[JSON](http://www.json.org/)?設定其分片和副本,下述創建了3個分片,2個副本的索引: ``` curl -XPUT 'localhost:9200/twitter?pretty' -d' { "settings" : { "index" : { "number_of_shards" : 3, "number_of_replicas" : 2 } } }' ``` ?或者簡化為: ``` curl -XPUT 'localhost:9200/twitter?pretty' -d' { "settings" : { "number_of_shards" : 3, "number_of_replicas" : 2 } }' ``` 注意:你不需要顯式的在?`settings`?中指定?`index`?。 關于在創建索引時所有不同的索引級別設置,請看?[index modules](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html "Index Modules")?部分。 ## Mappings/映射 創建索引允許提供包含一個或多個映射的設置: ``` ?curl -XPUT 'localhost:9200/test?pretty' -d' { "settings" : { "number_of_shards" : 1 }, "mappings" : { "type1" : { "properties" : { "field1" : { "type" : "text" } } } } }' ``` ## Aliases/別名 創建索引可以設置其別名: ``` ?curl -XPUT 'localhost:9200/test?pretty' -d' { "aliases" : { "alias_1" : {}, "alias_2" : { "filter" : { "term" : {"user" : "kimchy" } }, "routing" : "kimchy" } } }' ``` ## Wait For Active Shards/等待激活分片數量 默認情況下,創建索引會在必要主分片已經創建成功并運行或請求超時后返回HTTP響應。創建索引的返回的響應: ``` { "acknowledged": true, "shards_acknowledged": true } ``` `acknowledged`?表示是否在集群成功創建索引, 同時?`shards_acknowledged`?表示是否在超時之前成功創建運行必要的分片。?注意?`acknowledged`?和?`shards_acknowledged`?可能返回?`false`, 但是索引創建成功。這些值只是表明是否操作在超時之前完成。如果?`acknowledged`?是?`false`, 表示我們對集群更新 新創建的索引 操作超時,但它可能很快將被創建。如果?`shards_acknowledged`?是?`false`,表示我們必要的分片啟動?操作超時(默認只為主分片),即使集群成功更新新創建的索引 (i.e.?`acknowledged=true`). 我們可以通過設置?`index.write.wait_for_active_shards`?來改變默認的設置(注意:更改此設置也會影響 ?`wait_for_active_shards`??值在所有隨后的寫操作) ``` curl -XPUT 'localhost:9200/test?pretty' -d' { "settings": { "index.write.wait_for_active_shards": "2" } }' ``` 或者通過請求參數?`wait_for_active_shards`: ``` curl -XPUT 'localhost:9200/test?wait_for_active_shards=2&pretty' ``` 有關 wait_for_active_shards 及其可能的值可以在?[here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-wait-for-active-shards "Wait For Active Shardsedit")?找到。
                  <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>

                              哎呀哎呀视频在线观看