Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
elasticsearch-demo
提交
0c2278b4
E
elasticsearch-demo
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
elasticsearch-demo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
elasticsearch-demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0c2278b4
编写于
5月 10, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:es 练习
上级
70614a1a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
15 addition
and
7 deletion
+15
-7
src/test/java/es_01/TestDocument_01_get.java
src/test/java/es_01/TestDocument_01_get.java
+1
-1
src/test/java/es_01/TestDocument_02_get.java
src/test/java/es_01/TestDocument_02_get.java
+1
-1
src/test/java/es_01/TestDocument_04_add.java
src/test/java/es_01/TestDocument_04_add.java
+1
-1
src/test/java/es_01/TestDocument_05_add.java
src/test/java/es_01/TestDocument_05_add.java
+1
-1
src/test/java/es_01/TestDocument_06_add.java
src/test/java/es_01/TestDocument_06_add.java
+1
-1
src/test/java/es_01/TestDocument_07_add.java
src/test/java/es_01/TestDocument_07_add.java
+1
-1
src/test/java/es_01/TestDocument_08_update.java
src/test/java/es_01/TestDocument_08_update.java
+1
-1
src/test/java/es_01/TestDocument_10_bulk.java
src/test/java/es_01/TestDocument_10_bulk.java
+8
-0
未找到文件。
src/test/java/es_01/TestDocument_01_get.java
浏览文件 @
0c2278b4
...
@@ -37,7 +37,7 @@ public class TestDocument_01_get {
...
@@ -37,7 +37,7 @@ public class TestDocument_01_get {
//构建请求
//构建请求
GetRequest
getRequest
=
new
GetRequest
(
"test_post"
,
"1"
);
GetRequest
getRequest
=
new
GetRequest
(
"test_post"
,
"1"
);
//添加可选参数
//添加可选参数
String
[]
includes
=
new
String
[]{
"
user"
,
"message
"
};
String
[]
includes
=
new
String
[]{
"
id"
,
"comment
"
};
String
[]
excludes
=
Strings
.
EMPTY_ARRAY
;
String
[]
excludes
=
Strings
.
EMPTY_ARRAY
;
FetchSourceContext
fetchSourceContext
=
new
FetchSourceContext
(
true
,
includes
,
excludes
);
FetchSourceContext
fetchSourceContext
=
new
FetchSourceContext
(
true
,
includes
,
excludes
);
getRequest
.
fetchSourceContext
(
fetchSourceContext
);
getRequest
.
fetchSourceContext
(
fetchSourceContext
);
...
...
src/test/java/es_01/TestDocument_02_get.java
浏览文件 @
0c2278b4
...
@@ -36,7 +36,7 @@ public class TestDocument_02_get {
...
@@ -36,7 +36,7 @@ public class TestDocument_02_get {
//构建请求
//构建请求
GetRequest
getRequest
=
new
GetRequest
(
"test_post"
,
"1"
);
GetRequest
getRequest
=
new
GetRequest
(
"test_post"
,
"1"
);
//添加可选参数
//添加可选参数
String
[]
includes
=
new
String
[]{
"
user"
,
"messag
e"
};
String
[]
includes
=
new
String
[]{
"
id"
,
"titl
e"
};
String
[]
excludes
=
Strings
.
EMPTY_ARRAY
;
String
[]
excludes
=
Strings
.
EMPTY_ARRAY
;
FetchSourceContext
fetchSourceContext
=
new
FetchSourceContext
(
true
,
includes
,
excludes
);
FetchSourceContext
fetchSourceContext
=
new
FetchSourceContext
(
true
,
includes
,
excludes
);
getRequest
.
fetchSourceContext
(
fetchSourceContext
);
getRequest
.
fetchSourceContext
(
fetchSourceContext
);
...
...
src/test/java/es_01/TestDocument_04_add.java
浏览文件 @
0c2278b4
...
@@ -30,7 +30,7 @@ public class TestDocument_04_add {
...
@@ -30,7 +30,7 @@ public class TestDocument_04_add {
public
void
testAdd
()
throws
IOException
{
public
void
testAdd
()
throws
IOException
{
//构建请求
//构建请求
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
request
.
id
(
"
5
"
);
request
.
id
(
"
6
"
);
//构建文档数据
//构建文档数据
Map
<
String
,
Object
>
jsonMap
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
jsonMap
=
new
HashMap
<
String
,
Object
>();
jsonMap
.
put
(
"user"
,
"tomas"
);
jsonMap
.
put
(
"user"
,
"tomas"
);
...
...
src/test/java/es_01/TestDocument_05_add.java
浏览文件 @
0c2278b4
...
@@ -30,7 +30,7 @@ public class TestDocument_05_add {
...
@@ -30,7 +30,7 @@ public class TestDocument_05_add {
public
void
testAdd
()
throws
IOException
{
public
void
testAdd
()
throws
IOException
{
//构建请求
//构建请求
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
request
.
id
(
"
5
"
);
request
.
id
(
"
7
"
);
//构建文档数据
//构建文档数据
XContentBuilder
builder
=
XContentFactory
.
jsonBuilder
();
XContentBuilder
builder
=
XContentFactory
.
jsonBuilder
();
builder
.
startObject
();
builder
.
startObject
();
...
...
src/test/java/es_01/TestDocument_06_add.java
浏览文件 @
0c2278b4
...
@@ -28,7 +28,7 @@ public class TestDocument_06_add {
...
@@ -28,7 +28,7 @@ public class TestDocument_06_add {
public
void
testAdd
()
throws
IOException
{
public
void
testAdd
()
throws
IOException
{
//构建请求
//构建请求
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
request
.
id
(
"
5
"
);
request
.
id
(
"
9
"
);
//构建文档数据
//构建文档数据
request
.
source
(
"user"
,
"tomas"
,
request
.
source
(
"user"
,
"tomas"
,
"message"
,
"trying out es1"
,
"message"
,
"trying out es1"
,
...
...
src/test/java/es_01/TestDocument_07_add.java
浏览文件 @
0c2278b4
...
@@ -39,7 +39,7 @@ public class TestDocument_07_add {
...
@@ -39,7 +39,7 @@ public class TestDocument_07_add {
public
void
testAdd
()
throws
IOException
{
public
void
testAdd
()
throws
IOException
{
//构建请求
//构建请求
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
IndexRequest
request
=
new
IndexRequest
(
"test_post"
);
request
.
id
(
"
5
"
);
request
.
id
(
"
10
"
);
//构建文档数据
//构建文档数据
String
jsonString
=
"{\n"
+
String
jsonString
=
"{\n"
+
" \"user\":\"tomas\",\n"
+
" \"user\":\"tomas\",\n"
+
...
...
src/test/java/es_01/TestDocument_08_update.java
浏览文件 @
0c2278b4
...
@@ -36,7 +36,7 @@ public class TestDocument_08_update {
...
@@ -36,7 +36,7 @@ public class TestDocument_08_update {
@Test
@Test
public
void
testUpdate
()
throws
IOException
{
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
<>();
Map
<
String
,
Object
>
jsonMap
=
new
HashMap
<>();
jsonMap
.
put
(
"user"
,
"tomas Lee"
);
jsonMap
.
put
(
"user"
,
"tomas Lee"
);
request
.
doc
(
jsonMap
);
request
.
doc
(
jsonMap
);
...
...
src/test/java/es_01/TestDocument_10_bulk.java
浏览文件 @
0c2278b4
...
@@ -23,6 +23,14 @@ import org.springframework.test.context.junit4.SpringRunner;
...
@@ -23,6 +23,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
java.io.IOException
;
import
java.io.IOException
;
/**
* 批量操作
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/5/10 14:18
*/
@Slf4j
@Slf4j
@SpringBootTest
(
classes
=
SearchApplication
.
class
)
@SpringBootTest
(
classes
=
SearchApplication
.
class
)
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录