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
c248f4ac
authored
Jul 06, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
整合redis
parent
26d8bc65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
service/attr_service.go
service/attr_service.go
View file @
c248f4ac
...
@@ -2,6 +2,7 @@ package service
...
@@ -2,6 +2,7 @@ package service
import
(
import
(
"fmt"
"fmt"
"github.com/gomodule/redigo/redis"
_
"github.com/gomodule/redigo/redis"
_
"github.com/gomodule/redigo/redis"
"github.com/tidwall/gjson"
"github.com/tidwall/gjson"
"gopkg.in/olivere/elastic.v5"
"gopkg.in/olivere/elastic.v5"
...
@@ -9,6 +10,7 @@ import (
...
@@ -9,6 +10,7 @@ import (
"search_server/pkg/common"
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/config"
"search_server/pkg/es"
"search_server/pkg/es"
"search_server/pkg/gredis"
_
"search_server/pkg/gredis"
_
"search_server/pkg/gredis"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -46,8 +48,9 @@ func SearchAttr(attrOrigin, encap string) (goodsName string, err error) {
...
@@ -46,8 +48,9 @@ func SearchAttr(attrOrigin, encap string) (goodsName string, err error) {
numberR
,
_
:=
regexp
.
Compile
(
common
.
PureNumberRegular
)
numberR
,
_
:=
regexp
.
Compile
(
common
.
PureNumberRegular
)
pureNumber
:=
numberR
.
FindString
(
encap
)
pureNumber
:=
numberR
.
FindString
(
encap
)
//再去找对应属性
//再去找对应属性
//attrName, _ := redis.String(gredis.HGet("sku_map2", pureNumber))
redisConn
:=
gredis
.
Conn
(
"default_redis_read"
)
attrName
:=
""
defer
redisConn
.
Close
()
attrName
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"sku_map2"
,
pureNumber
))
if
attrName
!=
""
{
if
attrName
!=
""
{
attrValue
:=
attrName
+
"€"
+
pureNumber
attrValue
:=
attrName
+
"€"
+
pureNumber
attrsSlice
=
append
(
attrsSlice
,
attrValue
)
attrsSlice
=
append
(
attrsSlice
,
attrValue
)
...
@@ -200,8 +203,9 @@ func getAttrValueByAttr(attr string) (attrValue string) {
...
@@ -200,8 +203,9 @@ func getAttrValueByAttr(attr string) (attrValue string) {
}
}
}
else
{
}
else
{
//再去找没有单位的对应属性
//再去找没有单位的对应属性
//attrName, _ = redis.String(gredis.HGet("sku_map2", attr))
redisConn
:=
gredis
.
Conn
(
"default_redis_read"
)
attrName
:=
""
defer
redisConn
.
Close
()
attrName
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"sku_map2"
,
pureNumber
))
if
attrName
!=
""
{
if
attrName
!=
""
{
attrValue
=
attrName
+
"€"
+
attr
attrValue
=
attrName
+
"€"
+
attr
}
else
{
}
else
{
...
...
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