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
457e3ddb
authored
Jul 15, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' of
http://119.23.72.7/mushishixian/search_server
into dev
parents
46b0ef9e
644a3d90
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
5 deletions
service/ziyin_service.go
service/ziyin_service.go
View file @
457e3ddb
...
...
@@ -161,19 +161,17 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
query
:=
elastic
.
NewBoolQuery
()
if
(
len
(
req
)
>
0
){
for
k
,
v
:=
range
req
{
k_temp
:=
make
([]
string
,
0
)
if
strings
.
Contains
(
k
,
"/"
)
{
k_temp
=
strings
.
Split
(
k
,
"/"
)
if
len
(
k_temp
)
==
2
{
isok
:=
makeQuery
(
query
,
k_temp
,
&
goods_temp_status
,
&
v
,
&
keyword
)
isok
:=
makeQuery
(
query
,
source
,
k_temp
,
&
goods_temp_status
,
&
v
,
&
keyword
)
if
!
isok
{
continue
;
}
}
}
}
}
source
.
Query
(
query
)
...
...
@@ -181,7 +179,7 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
fmt
.
Println
(
res
)
}
func
makeQuery
(
query
*
elastic
.
BoolQuery
,
conditions
[]
string
,
goods_temp_status
*
int
,
searchValue
*
string
,
keyword
*
string
)
bool
{
func
makeQuery
(
query
*
elastic
.
BoolQuery
,
source
*
elastic
.
SearchSource
,
conditions
[]
string
,
goods_temp_status
*
int
,
searchValue
*
string
,
keyword
*
string
)
bool
{
var
(
err
error
...
...
@@ -202,6 +200,9 @@ func makeQuery(query *elastic.BoolQuery,conditions []string,goods_temp_status *i
redisConn
.
Close
()
}()
searchKey
=
strings
.
TrimSpace
(
searchKey
)
searchCondition
=
strings
.
TrimSpace
(
searchCondition
)
*
searchValue
=
strings
.
TrimSpace
(
*
searchValue
)
switch
searchCondition
{
case
"condition"
:
if
searchKey
!=
"status"
&&
searchCondition
==
""
{
...
...
@@ -322,9 +323,50 @@ func makeQuery(query *elastic.BoolQuery,conditions []string,goods_temp_status *i
query
.
Must
(
elastic
.
NewTermsQuery
(
searchKey
,
term_v_interface
))
}
case
"order"
:
orderSort
:=
false
if
strings
.
ToLower
(
*
searchValue
)
==
"asc"
{
orderSort
=
true
}
else
if
strings
.
ToLower
(
*
searchValue
)
==
"desc"
{
orderSort
=
false
}
source
.
Sort
(
searchKey
,
orderSort
)
case
"range"
:
paramsRange
:=
make
([]
int64
,
2
)
term_v
:=
make
([]
string
,
0
)
term_v
=
strings
.
Split
(
*
searchValue
,
","
)
if
len
(
term_v
)
>
0
{
for
i
:=
0
;
i
<=
len
(
term_v
)
-
1
;
i
++
{
if
term_v
[
i
]
!=
""
{
if
rangeGte
,
err
:=
strconv
.
ParseInt
(
term_v
[
i
],
10
,
64
);
err
==
nil
{
paramsRange
[
i
]
=
rangeGte
}
}
}
}
query
.
Must
(
elastic
.
NewRangeQuery
(
searchKey
)
.
Gte
(
paramsRange
[
0
])
.
Lte
(
paramsRange
[
1
]))
case
"sr"
:
term_v
:=
make
([]
string
,
0
)
term_v
=
strings
.
Split
(
*
searchValue
,
","
)
if
len
(
term_v
)
==
2
{
term_v0
:=
strings
.
ToLower
(
strings
.
TrimSpace
(
term_v
[
0
]))
term_v1
:=
strings
.
TrimSpace
(
term_v
[
1
])
if
term_v1_int
,
err
:=
strconv
.
ParseInt
(
term_v1
,
10
,
64
);
err
==
nil
{
if
php2go
.
InArray
(
term_v0
,[]
string
{
"gt"
,
"lt"
,
"gte"
,
"lte"
}){
rangequery
:=
elastic
.
NewRangeQuery
(
searchKey
)
if
term_v0
==
"gt"
{
rangequery
.
Gt
(
term_v1_int
)
}
else
if
(
term_v0
==
"lt"
){
rangequery
.
Lt
(
term_v1_int
)
}
else
if
(
term_v0
==
"gte"
){
rangequery
.
Gte
(
term_v1_int
)
}
else
if
(
term_v0
==
"lte"
){
rangequery
.
Lte
(
term_v1_int
)
}
query
.
Must
(
rangequery
)
}
}
}
case
"nested"
:
case
"eq"
:
}
...
...
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