Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
485aec3f
"ruoyi-ui/src/git@ustchcs.com:gujinli1118/RuoYi-Vue.git" did not exist on "d5cc95fefbb7dea269602b8b20d67c368d905369"
Commit
485aec3f
authored
Oct 14, 2022
by
macro
Browse files
搜索功能查询结果为空问题修复
parent
fe2f43f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
mall-search/src/main/java/com/macro/mall/search/service/impl/EsProductServiceImpl.java
View file @
485aec3f
package
com.macro.mall.search.service.impl
;
package
com.macro.mall.search.service.impl
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.macro.mall.search.dao.EsProductDao
;
import
com.macro.mall.search.dao.EsProductDao
;
import
com.macro.mall.search.domain.EsProduct
;
import
com.macro.mall.search.domain.EsProduct
;
...
@@ -162,7 +163,7 @@ public class EsProductServiceImpl implements EsProductService {
...
@@ -162,7 +163,7 @@ public class EsProductServiceImpl implements EsProductService {
LOGGER
.
info
(
"DSL:{}"
,
searchQuery
.
getQuery
().
toString
());
LOGGER
.
info
(
"DSL:{}"
,
searchQuery
.
getQuery
().
toString
());
SearchHits
<
EsProduct
>
searchHits
=
elasticsearchRestTemplate
.
search
(
searchQuery
,
EsProduct
.
class
);
SearchHits
<
EsProduct
>
searchHits
=
elasticsearchRestTemplate
.
search
(
searchQuery
,
EsProduct
.
class
);
if
(
searchHits
.
getTotalHits
()<=
0
){
if
(
searchHits
.
getTotalHits
()<=
0
){
return
new
PageImpl
<>(
null
,
pageable
,
0
);
return
new
PageImpl
<>(
ListUtil
.
empty
()
,
pageable
,
0
);
}
}
List
<
EsProduct
>
searchProductList
=
searchHits
.
stream
().
map
(
SearchHit:
:
getContent
).
collect
(
Collectors
.
toList
());
List
<
EsProduct
>
searchProductList
=
searchHits
.
stream
().
map
(
SearchHit:
:
getContent
).
collect
(
Collectors
.
toList
());
return
new
PageImpl
<>(
searchProductList
,
pageable
,
searchHits
.
getTotalHits
());
return
new
PageImpl
<>(
searchProductList
,
pageable
,
searchHits
.
getTotalHits
());
...
@@ -206,12 +207,12 @@ public class EsProductServiceImpl implements EsProductService {
...
@@ -206,12 +207,12 @@ public class EsProductServiceImpl implements EsProductService {
LOGGER
.
info
(
"DSL:{}"
,
searchQuery
.
getQuery
().
toString
());
LOGGER
.
info
(
"DSL:{}"
,
searchQuery
.
getQuery
().
toString
());
SearchHits
<
EsProduct
>
searchHits
=
elasticsearchRestTemplate
.
search
(
searchQuery
,
EsProduct
.
class
);
SearchHits
<
EsProduct
>
searchHits
=
elasticsearchRestTemplate
.
search
(
searchQuery
,
EsProduct
.
class
);
if
(
searchHits
.
getTotalHits
()<=
0
){
if
(
searchHits
.
getTotalHits
()<=
0
){
return
new
PageImpl
<>(
null
,
pageable
,
0
);
return
new
PageImpl
<>(
ListUtil
.
empty
()
,
pageable
,
0
);
}
}
List
<
EsProduct
>
searchProductList
=
searchHits
.
stream
().
map
(
SearchHit:
:
getContent
).
collect
(
Collectors
.
toList
());
List
<
EsProduct
>
searchProductList
=
searchHits
.
stream
().
map
(
SearchHit:
:
getContent
).
collect
(
Collectors
.
toList
());
return
new
PageImpl
<>(
searchProductList
,
pageable
,
searchHits
.
getTotalHits
());
return
new
PageImpl
<>(
searchProductList
,
pageable
,
searchHits
.
getTotalHits
());
}
}
return
new
PageImpl
<>(
null
);
return
new
PageImpl
<>(
ListUtil
.
empty
()
);
}
}
@Override
@Override
...
...
Write
Preview
Supports
Markdown
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