Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
shop
Commits
6d2166d2
Commit
6d2166d2
authored
Oct 13, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化搜索API
parent
b0744e26
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
SolrGoodsController.java
...n/java/com/egolm/shop/controller/SolrGoodsController.java
+5
-2
SolrGoodsService.java
src/main/java/com/egolm/shop/service/SolrGoodsService.java
+1
-1
SolrGoodsServiceImpl.java
...ava/com/egolm/shop/service/impl/SolrGoodsServiceImpl.java
+7
-6
No files found.
src/main/java/com/egolm/shop/controller/SolrGoodsController.java
View file @
6d2166d2
...
...
@@ -10,6 +10,7 @@ import com.egolm.common.jdbc.Page;
import
com.egolm.shop.service.SolrGoodsService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
@Api
...
...
@@ -23,8 +24,10 @@ public class SolrGoodsController {
@ResponseBody
@RequestMapping
(
"query"
)
@ApiOperation
(
"搜索引擎商品搜索"
)
public
Object
query
(
Page
page
,
String
queryKey
,
String
[]
keywords
,
String
[]
orders
,
String
[]
facetFields
,
String
[]
facetPivotFields
)
{
return
service
.
query
(
page
,
queryKey
,
keywords
,
orders
,
facetFields
,
facetPivotFields
);
@ApiImplicitParams
({
})
public
Object
query
(
Page
page
,
String
queryKey
,
String
[]
keywords
,
String
[]
facetFields
,
String
[]
facetPivotFields
)
{
return
service
.
query
(
page
,
queryKey
,
keywords
,
facetFields
,
facetPivotFields
);
}
@ResponseBody
...
...
src/main/java/com/egolm/shop/service/SolrGoodsService.java
View file @
6d2166d2
...
...
@@ -5,7 +5,7 @@ import com.egolm.common.jdbc.Page;
public
interface
SolrGoodsService
{
public
Rjx
query
(
Page
page
,
String
queryKey
,
String
[]
keywords
,
String
[]
orders
,
String
[]
facetFields
,
String
[]
facetPivotFields
);
public
Rjx
query
(
Page
page
,
String
queryKey
,
String
[]
keywords
,
String
[]
facetFields
,
String
[]
facetPivotFields
);
public
void
update
();
...
...
src/main/java/com/egolm/shop/service/impl/SolrGoodsServiceImpl.java
View file @
6d2166d2
...
...
@@ -42,8 +42,8 @@ public class SolrGoodsServiceImpl implements SolrGoodsService {
private
HttpSolrClient
solrClient
;
@Override
public
Rjx
query
(
Page
page
,
String
queryKey
,
String
[]
keywords
,
String
[]
orders
,
String
[]
facetFields
,
String
[]
facetPivotFields
)
{
logger
.
info
(
"收到商品检索请求:"
+
Rjx
.
json
().
set
(
"page"
,
page
).
set
(
"queryKey"
,
queryKey
).
set
(
"keywords"
,
keywords
).
set
(
"
orders"
,
orders
).
set
(
"
facetFields"
,
facetFields
).
set
(
"facetPivotFields"
,
facetPivotFields
));
public
Rjx
query
(
Page
page
,
String
queryKey
,
String
[]
keywords
,
String
[]
facetFields
,
String
[]
facetPivotFields
)
{
logger
.
info
(
"收到商品检索请求:"
+
Rjx
.
json
().
set
(
"page"
,
page
).
set
(
"queryKey"
,
queryKey
).
set
(
"keywords"
,
keywords
).
set
(
"facetFields"
,
facetFields
).
set
(
"facetPivotFields"
,
facetPivotFields
));
if
(
page
==
null
)
{
page
=
new
Page
(
1L
,
20L
);
}
...
...
@@ -57,9 +57,10 @@ public class SolrGoodsServiceImpl implements SolrGoodsService {
solrQuery
.
addFilterQuery
(
keyword
);
}
}
if
(
orders
!=
null
)
{
for
(
String
order
:
orders
)
{
String
[]
kv
=
order
.
split
(
":"
,
2
);
String
[]
limitKeys
=
page
.
getLimitKey
();
if
(
limitKeys
!=
null
)
{
for
(
String
key
:
limitKeys
)
{
String
[]
kv
=
key
.
split
(
" "
,
2
);
ORDER
sc
=
kv
[
1
]
==
null
||
kv
[
1
].
trim
().
length
()
==
0
||
kv
[
1
].
equalsIgnoreCase
(
"asc"
)
?
ORDER
.
asc
:
ORDER
.
desc
;
solrQuery
.
addSort
(
kv
[
0
],
sc
);
}
...
...
@@ -150,7 +151,7 @@ public class SolrGoodsServiceImpl implements SolrGoodsService {
}
@Override
public
void
deleteById
(
String
...
documentIds
)
{
public
void
deleteById
(
String
[]
documentIds
)
{
try
{
solrClient
.
deleteById
(
Arrays
.
asList
(
documentIds
));
solrClient
.
commit
();
...
...
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