<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 索引API ``` IndexRequest request = new IndexRequest("posts"); #1 request.id("1"); #2 String jsonString = "{" + "\"user\":\"kimchy\"," + "\"postDate\":\"2013-01-30\"," + "\"message\":\"trying out Elasticsearch\"" + "}"; request.source(jsonString, XContentType.JSON); #3 ``` * 1 index 索引名 * 2 document id 文檔id * 3 document source 文檔資源,類似于關系型數據庫表的一行內容 ### source #### map ``` Map<String, Object> jsonMap = new HashMap<>(); jsonMap.put("user", "kimchy"); jsonMap.put("postDate", new Date()); jsonMap.put("message", "trying out Elasticsearch"); IndexRequest indexRequest = new IndexRequest("posts") .id("1").source(jsonMap); ``` 提供為的document source,該`Map`自動轉換為JSON格式 #### XcontentBuilder ``` XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject(); { builder.field("user", "kimchy"); builder.timeField("postDate", new Date()); builder.field("message", "trying out Elasticsearch"); } builder.endObject(); IndexRequest indexRequest = new IndexRequest("posts") .id("1").source(builder); ``` 作為`XContentBuilder`對象提供的文檔源,Elasticsearch內置幫助器可生成JSON內容 ``` IndexRequest indexRequest = new IndexRequest("posts") .id("1") .source("user", "kimchy", "postDate", new Date(), "message", "trying out Elasticsearch"); ``` 作為`Object`key-pairs提供的文檔源,被轉換為JSON格式 ## 可選參數 ### 路由 ``` request.routing("routing"); ``` ### 等待primary shard超時設置 ``` request.timeout(TimeValue.timeValueSeconds(1)); //TimeValue request.timeout("1s");//string 兩種方式等值 ``` ### 刷新策略 ``` request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); request.setRefreshPolicy("wait_for"); ``` ### version--版本 ``` request.version(2) ``` ### Version type ``` request.opType(DocWriteRequest.OpType.CREATE); //提供DocWriteRequest.OpType值的操作類型 request.opType("create");//以String:提供的操作類型可以是create或index(默認) ``` ### pipeline ``` request.setPipeline("pipeline"); ``` The name of the ingest pipeline to be executed before indexing the document ## Syschronous excution 同步執行 ~~~ IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT); ~~~ ## Asynchronnou execution 異步執行 ~~~ client.indexAsync(request, RequestOptions.DEFAULT, listener); ~~~ A typical listener for`index`looks like: ``` listener = new ActionListener<IndexResponse>() { @Override public void onResponse(IndexResponse indexResponse) { } @Override public void onFailure(Exception e) { } }; ``` ### Index Response ~~~ String index = indexResponse.getIndex(); String id = indexResponse.getId(); if (indexResponse.getResult() == DocWriteResponse.Result.CREATED) { } else if (indexResponse.getResult() == DocWriteResponse.Result.UPDATED) { } ReplicationResponse.ShardInfo shardInfo = indexResponse.getShardInfo(); if (shardInfo.getTotal() != shardInfo.getSuccessful()) { } if (shardInfo.getFailed() > 0) { for (ReplicationResponse.ShardInfo.Failure failure : shardInfo.getFailures()) { String reason = failure.reason(); } } ~~~ 處理(如果需要)首次創建文檔的情況 處理(如果需要)已存在的文檔被重寫的情況 處理成功分片數量少于總分片數量的情況 處理潛在的故障
                  <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>

                              哎呀哎呀视频在线观看