Skip to content

Commit

Permalink
es for index
Browse files Browse the repository at this point in the history
  • Loading branch information
caochengxiang committed Jun 29, 2023
1 parent 36f9dab commit 17babf7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jcommon/es/src/main/java/com/xiaomi/mone/es/EsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ public void insertDoc(String index, Map<String, Object> data, String id) throws
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
}

public void insertDocForIndex(String index, Map<String, Object> data) throws IOException {
IndexRequest indexRequest = new IndexRequest(index, "_doc", UUID.randomUUID().toString()).source(data);
indexRequest.opType(DocWriteRequest.OpType.INDEX);
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
}

public void insertDocForIndex(String index, Map<String, Object> data, String id) throws IOException {
IndexRequest indexRequest = new IndexRequest(index, "_doc", id).source(data);
indexRequest.opType(DocWriteRequest.OpType.INDEX);
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
}

public void insertDocJson(String index, String jsonString) throws IOException {
IndexRequest indexRequest = new IndexRequest(index, "_doc", UUID.randomUUID().toString()).source(jsonString, XContentType.JSON);
indexRequest.opType(DocWriteRequest.OpType.CREATE);
Expand Down

0 comments on commit 17babf7

Please sign in to comment.