Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fb1489f8
authored
Nov 20, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
e9e8acda
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
routes/router.go
service/query/optimum_query.go
routes/router.go
View file @
fb1489f8
...
...
@@ -15,7 +15,7 @@ func InitRouter() *gin.Engine {
r
.
Use
(
middleware
.
Cors
())
//健康监测
r
.
POST
(
"
Health
"
,
func
(
c
*
gin
.
Context
)
{
r
.
POST
(
"
hbsdata
"
,
func
(
c
*
gin
.
Context
)
{
c
.
String
(
200
,
"ok"
)
})
...
...
service/query/optimum_query.go
View file @
fb1489f8
package
query
import
(
"errors"
"github.com/gin-gonic/gin"
"gopkg.in/olivere/elastic.v5"
"search_server/pkg/common"
...
...
@@ -21,11 +20,14 @@ func GetOptimumAttrQuery(ctx *gin.Context,REQUEST_ATTR *map[string][]string,type
//query1 := elastic.NewBoolQuery()
//query2 := elastic.NewBoolQuery()
//一级分类查询
class_id1
:=
ctx
.
Request
.
FormValue
(
"class_id1"
)
if
class_id1
!=
""
{
query
.
Must
(
elastic
.
NewTermQuery
(
"class_id1"
,
class_id1
))
}
//二级分类查询
class_id2
:=
ctx
.
Request
.
FormValue
(
"class_id2"
)
if
class_id2
==
""
{
return
""
,
errors
.
New
(
"二级分类不得为空"
)
}
else
{
if
class_id2
!=
""
{
query
.
Must
(
elastic
.
NewTermQuery
(
"class_id2"
,
class_id2
))
}
if
ctx
.
Request
.
FormValue
(
"avail_rank"
)
==
"1"
{
//只显示有货
...
...
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