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

                # 創建索引 1.創建索引 ES的API組成結構:使用RESTful API風格來命名API ``` API基本格式:http://<ip>:<port>/<索引>/<類型>/<文檔id> 常用HTTP動詞 ``` >常用HTTP動詞:GET/PUT/POST/DELETE >>PUT 執行創建或修改,如確定document的ID時 >>POST一般用于改變對象或查詢,如不確定document的ID,可以直接POST, ES可以 自己生成不會發生碰撞的UUID >>GET一般用于查詢 >>DELETE用于刪除 >>HEAD請求獲取對象的基礎信息,如檢查文檔是否存在 我們現在有一個業務需求就是存儲訂單數據,需要創建訂單文檔,如下操作: >一個文檔必須的三個元數據元素如下 _index文檔在哪存放 _type文檔表示的對象類別 _id文檔唯一標識,id可以自己指定,也可以自動生成 #####假設構建了的表如下: 是否主鍵|字段名|字段描述|數據類型|分詞 -|-|-| 是|orderId|訂單ID|long|否 否|userId|用戶ID|long|否 否|orderNo|訂單號|string|否 否|userName|用戶名|string|否 否|totalPrice|價格|float|否 否|address|收貨地址|string|是 否|createTime|創建時間|data|否 如果不創建mapping,ES會根據文檔的字段數據自動識別類型 這里需要創建自己定義的mapping #####創建自定義mapping PUT或者POST ``` PUT /order_index/_mapping/order_type/ { "order_type": { "properties": { "orderId": { "type": "long" }, "userId": { "type": "long" }, "userName": { "type": "text" }, "totalPrice": { "type": "float" }, "address": { "type": "text", "analyzer": "ik_smart", "search_analyzer": "ik_smart" }, "createTime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" } } } } ``` ![](https://box.kancloud.cn/e6d6c55807a6f00cb49a984d6625ba49_865x633.png) ![](https://box.kancloud.cn/3a021721d31f11ed41823ec9246470eb_543x477.png) 1.建立order_index索引 2.在order_index下建立order_type類型 3.每個訂單數據是一個文檔 簡單的創建索引方式,只能使用PUT創建 ```\` PUT /order_index/ ``` 簡單的創建類型方式,只能使用POST,除非指定document的ID ``` POST /order_index/order_type/ ``` ![](https://box.kancloud.cn/2901acc83c1c6460bb64bdb91da35d75_638x366.png) 以上創建索引和類型可以通過一條命令完成 ``` PUT /order_index/order_type/1 { "orderId":10001, "userId":10001, "orderNo":"a10001", "userName":"John", "totalPrice":50.00, "address":"江蘇省南京市江寧區XXX", "createTime":"2018-05-16 14:08:00" } ``` ![](https://box.kancloud.cn/527c7d32d988bf9284042d24ef10ab46_633x340.png)
                  <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>

                              哎呀哎呀视频在线观看