Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
L
library
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
stbz
library
Commits
00965c9e
提交
00965c9e
authored
1月 12, 2022
作者:
limeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改批量
上级
c8d92aa2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
11 行删除
+14
-11
service.go
elastic/service.go
+11
-11
struct.go
elastic/struct.go
+3
-0
没有找到文件。
elastic/service.go
浏览文件 @
00965c9e
...
...
@@ -53,7 +53,7 @@ func GetCount(req GetCountReq) (count int64,err error) {
}
//根据搜索条件 获取数据
func
GetList
(
req
GetListReq
)
(
searchResult
*
elastic
.
SearchResult
)
{
func
GetList
(
req
GetListReq
)
(
searchResult
*
elastic
.
SearchResult
,
err
error
)
{
//检测是from_size查询还是search_after滚动式查询
isSearchAfter
,
from
,
size
:=
checkParam
(
req
)
//连接Es
...
...
@@ -82,7 +82,7 @@ func GetList(req GetListReq) (searchResult *elastic.SearchResult) {
Do
(
ctx
)
}
return
searchResult
return
}
//检验参数 区分 分页查询 滚动式查询
...
...
@@ -107,11 +107,11 @@ func Bulk(req BulkReq) (bulkIndex *BulkIndex, err error) {
switch
req
.
Type
{
case
"add"
:
bulkIndexAdd
=
BulkAdd
(
req
.
IndexName
)
bulkIndexAdd
=
BulkAdd
(
req
)
case
"update"
:
bulkIndexUpdate
=
BulkUpdate
(
req
.
IndexName
)
bulkIndexUpdate
=
BulkUpdate
(
req
)
case
"del"
:
bulkIndexDel
=
BulkDel
(
req
.
IndexName
)
bulkIndexDel
=
BulkDel
(
req
)
}
if
bulkIndexAdd
!=
nil
{
...
...
@@ -127,20 +127,20 @@ func Bulk(req BulkReq) (bulkIndex *BulkIndex, err error) {
}
//批量处理 准备数据 1.添加
func
BulkAdd
(
indexName
string
)
(
indexReq
*
elastic
.
BulkIndexRequest
)
{
indexReq
=
elastic
.
NewBulkIndexRequest
()
.
Index
(
indexName
)
.
Type
(
docType
)
func
BulkAdd
(
req
BulkReq
)
(
indexReq
*
elastic
.
BulkIndexRequest
)
{
indexReq
=
elastic
.
NewBulkIndexRequest
()
.
Index
(
req
.
IndexName
)
.
Type
(
docType
)
.
Id
(
req
.
DocId
)
.
Routing
(
req
.
RoutingId
)
.
Doc
(
req
.
Doc
)
return
}
//批量处理 准备数据 1.删除
func
BulkDel
(
indexName
string
)
(
indexReq
*
elastic
.
BulkDeleteRequest
)
{
indexReq
=
elastic
.
NewBulkDeleteRequest
()
.
Index
(
indexName
)
.
Type
(
docType
)
func
BulkDel
(
req
BulkReq
)
(
indexReq
*
elastic
.
BulkDeleteRequest
)
{
indexReq
=
elastic
.
NewBulkDeleteRequest
()
.
Index
(
req
.
IndexName
)
.
Type
(
docType
)
.
Id
(
req
.
DocId
)
.
Routing
(
req
.
RoutingId
)
return
}
//批量处理 准备数据 1.更新
func
BulkUpdate
(
indexName
string
)
(
indexReq
*
elastic
.
BulkUpdateRequest
)
{
indexReq
=
elastic
.
NewBulkUpdateRequest
()
.
Index
(
indexName
)
.
Type
(
docType
)
func
BulkUpdate
(
req
BulkReq
)
(
indexReq
*
elastic
.
BulkUpdateRequest
)
{
indexReq
=
elastic
.
NewBulkUpdateRequest
()
.
Index
(
req
.
IndexName
)
.
Type
(
docType
)
.
Id
(
req
.
DocId
)
.
Routing
(
req
.
RoutingId
)
.
Doc
(
req
.
Doc
)
return
}
...
...
elastic/struct.go
浏览文件 @
00965c9e
...
...
@@ -5,6 +5,9 @@ import "github.com/olivere/elastic/v7"
type
BulkReq
struct
{
Type
string
`json:"type"`
IndexName
string
`json:"index_name"`
DocId
string
`json:"doc_id"`
RoutingId
string
`json:"routing_id"`
Doc
interface
{}
`json:"doc"`
}
type
BulkIndex
struct
{
*
elastic
.
BulkIndexRequest
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论