Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
08a645e4
Commit
08a645e4
authored
Aug 21, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
es随机查询,过滤数据
parent
ba9f93dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
13 deletions
+114
-13
ch-dao/src/main/java/com/wwdz/ch/db/bean/ItemOfEs.java
ch-dao/src/main/java/com/wwdz/ch/db/bean/ItemOfEs.java
+104
-7
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
+10
-6
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/bean/ItemOfEs.java
View file @
08a645e4
...
@@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
...
@@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import
com.xxdxxs.entity.Entity
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Date
;
@Data
@Data
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
ItemOfEs
implements
Entity
{
public
class
ItemOfEs
implements
Entity
{
...
@@ -12,22 +14,117 @@ public class ItemOfEs implements Entity {
...
@@ -12,22 +14,117 @@ public class ItemOfEs implements Entity {
private
Long
id
;
private
Long
id
;
/**
/**
* 商品
id
* 商品
名称
*/
*/
private
String
coin_id
;
private
String
name
;
/**
/**
* 商品
名称
* 商品
所属类目ID
*/
*/
private
String
name
;
private
Integer
cid
;
/**
* 是否上架
*/
private
Boolean
isOnSale
;
/**
* 是否标准件
*/
private
Boolean
isStd
;
/**
* 排序
*/
private
Integer
sort
;
/**
* 商品分享朋友圈图片
*/
private
String
shareImage
;
/**
/**
* 置顶图片
* 置顶图片
*/
*/
private
String
top_image_path
;
private
String
topImage
;
/**
* 价格, 要除以100
*/
private
Long
price
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 来源类型(1系统2用户上传)
*/
private
Integer
sourceType
;
/**
* 更新时间
*/
private
Date
updateTime
;
/**
* 逻辑删除
*/
private
Boolean
isDeleted
;
/**
* 成交时间
*/
private
String
bidTime
;
/**
* 备注说明
*/
private
String
remark
;
/**
* 是否设置过
*/
private
Integer
isSetted
;
/**
* 原始的资源url
*/
private
String
originalSourceUrl
;
/**
* 来源7(1,2,3,,8,10,11):中国的
*/
private
Integer
source
;
/**
* 商品种类1钱币
*/
private
Integer
kind
;
/**
* 商品额外信息
*/
private
String
extra
;
/**
* 商品图片,分号分隔
*/
private
String
images
;
/**
* 商品视频, 分号分隔
*/
private
String
videos
;
/**
* 商品详细介绍,是富文本格式
*/
private
String
detail
;
/**
/**
*
价格
*
原始额外信息
*/
*/
private
String
price
;
private
String
originalExtra
;
}
}
ch-dao/src/main/java/com/wwdz/ch/db/es/ItemEsDao.java
View file @
08a645e4
...
@@ -33,7 +33,11 @@ public class ItemEsDao {
...
@@ -33,7 +33,11 @@ public class ItemEsDao {
private
final
static
String
INDEX
=
"quanku_temp"
;
private
final
static
String
INDEX
=
"quanku_temp"
;
//商品来源是中国,所对应的编码
//商品来源是中国,所对应的编码
private
final
static
List
<
String
>
CHINESE_SOURCE_LIST
=
Arrays
.
asList
(
"1"
,
"2"
,
"3"
,
"7"
,
"8"
,
"10"
,
"11"
,
"1000"
);
private
final
static
List
<
String
>
CHINESE_SOURCE_LIST
=
Arrays
.
asList
(
"1"
,
"2"
,
"3"
,
"7"
,
"11"
,
"1000"
);
//来源中国,排除2,7,尚未去除水印的
private
final
static
List
<
String
>
SOURCE_LIST
=
Arrays
.
asList
(
"1"
,
"3"
,
"8"
,
"11"
,
"1000"
);
@Resource
(
name
=
"clientByPasswd"
)
@Resource
(
name
=
"clientByPasswd"
)
ElasticsearchClient
elasticsearchClient
;
ElasticsearchClient
elasticsearchClient
;
...
@@ -75,13 +79,13 @@ public class ItemEsDao {
...
@@ -75,13 +79,13 @@ public class ItemEsDao {
int
page
=
esSearchRequestDto
.
getPage
();
int
page
=
esSearchRequestDto
.
getPage
();
int
size
=
esSearchRequestDto
.
getSize
();
int
size
=
esSearchRequestDto
.
getSize
();
int
from
=
(
page
-
1
)
*
size
;
int
from
=
(
page
-
1
)
*
size
;
Query
sourceTermQuery
=
TermQuery
.
of
(
t
->
/*
Query sourceTermQuery = TermQuery.of(t ->
t.field("source")
t.field("source")
.value(2))._toQuery();
.value(2))._toQuery();
Query sourceTermQuery2 = TermQuery.of(t ->
Query sourceTermQuery2 = TermQuery.of(t ->
t.field("source")
t.field("source")
.
value
(
7
)).
_toQuery
();
.value(7))._toQuery();
*/
SearchRequest
.
Builder
builder
=
new
SearchRequest
.
Builder
();
SearchRequest
.
Builder
builder
=
new
SearchRequest
.
Builder
();
builder
.
index
(
INDEX
);
builder
.
index
(
INDEX
);
...
@@ -89,13 +93,13 @@ public class ItemEsDao {
...
@@ -89,13 +93,13 @@ public class ItemEsDao {
builder
.
source
(
sourceBuild
->
sourceBuild
.
filter
(
f
->
f
.
includes
(
esSearchRequestDto
.
getIncludes
())));
builder
.
source
(
sourceBuild
->
sourceBuild
.
filter
(
f
->
f
.
includes
(
esSearchRequestDto
.
getIncludes
())));
}
}
List
<
Query
>
sourceTypeQueryList
=
new
ArrayList
<>();
List
<
Query
>
sourceTypeQueryList
=
new
ArrayList
<>();
CHINESE_
SOURCE_LIST
.
forEach
(
i
->
{
SOURCE_LIST
.
forEach
(
i
->
{
Query
query
=
TermQuery
.
of
(
t
->
t
.
field
(
"source
Type
"
).
value
(
i
)).
_toQuery
();
Query
query
=
TermQuery
.
of
(
t
->
t
.
field
(
"source"
).
value
(
i
)).
_toQuery
();
sourceTypeQueryList
.
add
(
query
);
sourceTypeQueryList
.
add
(
query
);
});
});
Query
shouldQuery
=
QueryBuilders
.
bool
(
q
->
q
.
should
(
sourceTypeQueryList
));
Query
shouldQuery
=
QueryBuilders
.
bool
(
q
->
q
.
should
(
sourceTypeQueryList
));
BoolQuery
.
Builder
build
=
QueryBuilders
.
bool
().
must
Not
(
sourceTermQuery
).
mustNot
(
sourceTermQuery2
).
must
(
shouldQuery
);
BoolQuery
.
Builder
build
=
QueryBuilders
.
bool
().
must
(
shouldQuery
);
if
(
StringUtils
.
hasLength
(
esSearchRequestDto
.
getContent
()))
{
if
(
StringUtils
.
hasLength
(
esSearchRequestDto
.
getContent
()))
{
Query
matchQuery
=
MatchQuery
.
of
(
m
->
m
Query
matchQuery
=
MatchQuery
.
of
(
m
->
m
.
field
(
"name"
)
.
field
(
"name"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment