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
92478a76
authored
Oct 29, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
7250594f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
service/query/optimum_query.go
service/query/optimum_query.go
View file @
92478a76
...
...
@@ -4,9 +4,11 @@ import (
"errors"
"github.com/gin-gonic/gin"
"gopkg.in/olivere/elastic.v5"
"regexp"
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/gredis"
"strings"
)
/*
...
...
@@ -31,8 +33,12 @@ func GetOptimumAttrQuery(ctx *gin.Context,REQUEST_ATTR *map[string][]string,type
if
ctx
.
Request
.
FormValue
(
"avail_rank"
)
==
"1"
{
//只显示有货
query
.
Must
(
elastic
.
NewRangeQuery
(
"stock"
)
.
Gt
(
0
))
}
if
ctx
.
Request
.
FormValue
(
"goods_name/condition"
)
!=
""
{
//型号搜索
query
.
Must
(
elastic
.
NewTermQuery
(
"goods_name"
,
ctx
.
Request
.
FormValue
(
"goods_name/condition"
)))
goods_name
:=
ctx
.
Request
.
FormValue
(
"goods_name/condition"
)
if
goods_name
!=
""
{
//型号搜索
replace
,
_
:=
regexp
.
Compile
(
"[^A-Za-z0-9]+"
)
goods_name
=
replace
.
ReplaceAllString
(
goods_name
,
""
)
goods_name
=
strings
.
ToUpper
(
goods_name
)
query
.
Must
(
elastic
.
NewTermQuery
(
"goods_name"
,
goods_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