这里写目录标题
一、文档APIs
Java 高级 REST 客户端支持以下文档 API:
1.单文档 API
Index API
1.IndexRequest
1.一个IndexRequest需要以下参数:
IndexRequest request = new IndexRequest("posts"); //参数一
request.id("1"); //参数二
String jsonString = "{" +
"\"user\":\"kimchy\"," +
"\"postDate\":\"2013-01-30\"," +
"\"message\":\"trying out Elasticsearch\"" +
"}";
request.source(jsonString, XContentType.JSON); //参数三
指数
请求的文档 ID
提供的文档来源String
2.提供文件来源
String除了上面显示的示例之外,还可以通过不同的方式提供文档源 :
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); // 提供的文档源Map自动转换为 JSON 格式
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject()
官方文档中文翻译&spm=1001.2101.3001.11974&articleId=124257012&d=1&t=3&u=fe6bc5897896486d98f6011e22bfe64a)


390


官方文档中文翻译&spm=1001.2101.3001.11976&articleId=124257012&d=1&t=3&u=98238e6ba33e48d6ac5a0233542b15a6)

被折叠的 条评论
为什么被折叠?



