fix:es 练习

上级 70614a1a
......@@ -37,7 +37,7 @@ public class TestDocument_01_get {
//构建请求
GetRequest getRequest = new GetRequest("test_post", "1");
//添加可选参数
String[] includes = new String[]{"user", "message"};
String[] includes = new String[]{"id", "comment"};
String[] excludes = Strings.EMPTY_ARRAY;
FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes);
getRequest.fetchSourceContext(fetchSourceContext);
......
......@@ -36,7 +36,7 @@ public class TestDocument_02_get {
//构建请求
GetRequest getRequest = new GetRequest("test_post", "1");
//添加可选参数
String[] includes = new String[]{"user", "message"};
String[] includes = new String[]{"id", "title"};
String[] excludes = Strings.EMPTY_ARRAY;
FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes);
getRequest.fetchSourceContext(fetchSourceContext);
......
......@@ -30,7 +30,7 @@ public class TestDocument_04_add {
public void testAdd() throws IOException {
//构建请求
IndexRequest request = new IndexRequest("test_post");
request.id("5");
request.id("6");
//构建文档数据
Map<String, Object> jsonMap = new HashMap<String, Object>();
jsonMap.put("user", "tomas");
......
......@@ -30,7 +30,7 @@ public class TestDocument_05_add {
public void testAdd() throws IOException {
//构建请求
IndexRequest request = new IndexRequest("test_post");
request.id("5");
request.id("7");
//构建文档数据
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
......
......@@ -28,7 +28,7 @@ public class TestDocument_06_add {
public void testAdd() throws IOException {
//构建请求
IndexRequest request = new IndexRequest("test_post");
request.id("5");
request.id("9");
//构建文档数据
request.source("user", "tomas",
"message", "trying out es1",
......
......@@ -39,7 +39,7 @@ public class TestDocument_07_add {
public void testAdd() throws IOException {
//构建请求
IndexRequest request = new IndexRequest("test_post");
request.id("5");
request.id("10");
//构建文档数据
String jsonString = "{\n" +
" \"user\":\"tomas\",\n" +
......
......@@ -36,7 +36,7 @@ public class TestDocument_08_update {
@Test
public void testUpdate() throws IOException {
//创建请求
UpdateRequest request = new UpdateRequest("test_post", "3");
UpdateRequest request = new UpdateRequest("test_post", "5");
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("user", "tomas Lee");
request.doc(jsonMap);
......
......@@ -23,6 +23,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
/**
* 批量操作
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/5/10 14:18
*/
@Slf4j
@SpringBootTest(classes = SearchApplication.class)
@RunWith(SpringRunner.class)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册