Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
suggest-task
Overview
Overview
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
田川
suggest-task
Commits
6249c39b
Commit
6249c39b
authored
Sep 24, 2019
by
davidstark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据海亮意见,修改部分代码
parent
2ff355ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
40 deletions
+23
-40
suggest-task.go
main/suggest-task.go
+12
-20
suggest-task.go
product/suggest-task.go
+11
-20
No files found.
main/suggest-task.go
View file @
6249c39b
...
...
@@ -44,9 +44,6 @@ type Word struct {
WordRank
float64
`json:"wordRank"`
KeywordVersion
string
`json:"keywordVersion"`
}
const
BRAND_TYPE
=
"1"
const
CATEGORY_TYPE
=
"2"
const
MANUAL_TYPE
=
"3"
var
wordMap
sync
.
Map
var
brandMap
=
make
(
map
[
string
]
int
)
...
...
@@ -118,30 +115,25 @@ func main() {
}
func
checkUnusedData
(
bulkProcessor
*
elastic
.
BulkProcessor
)
{
var
tmpMap
=
make
(
map
[
string
]
bool
)
for
brand
:=
range
brandMap
{
if
_
,
exist
:=
usedMap
.
Load
(
brand
+
BRAND_TYPE
);
!
exist
{
addWord
(
brand
,
bulkProcessor
,
BRAND_TYPE
)
}
tmpMap
[
brand
]
=
true
;
}
for
category
:=
range
categoryMap
{
if
_
,
exist
:=
usedMap
.
Load
(
category
+
CATEGORY_TYPE
);
!
exist
{
addWord
(
category
,
bulkProcessor
,
CATEGORY_TYPE
)
}
tmpMap
[
category
]
=
true
}
for
manual
:=
range
manualMap
{
if
_
,
exist
:=
usedMap
.
Load
(
manual
+
MANUAL_TYPE
);
!
exist
{
addWord
(
manual
,
bulkProcessor
,
MANUAL_TYPE
)
tmpMap
[
manual
]
=
true
}
for
word
:=
range
tmpMap
{
if
_
,
exist
:=
usedMap
.
Load
(
word
);
!
exist
{
addWord
(
word
,
bulkProcessor
)
}
}
}
func
addWord
(
keyword
string
,
processor
*
elastic
.
BulkProcessor
,
wordType
string
)
{
func
addWord
(
keyword
string
,
processor
*
elastic
.
BulkProcessor
)
{
var
w
=
new
(
Word
)
switch
wordType
{
case
BRAND_TYPE
:
w
.
IsBrand
=
true
case
CATEGORY_TYPE
:
w
.
IsCategory
=
true
case
MANUAL_TYPE
:
{
w
.
IsManual
=
true
;
w
.
ManualValue
=
manualMap
[
keyword
]}
}
w
.
Keyword
=
keyword
w
.
KeywordVersion
=
dateStr
processWord
(
w
)
...
...
@@ -344,18 +336,18 @@ func processWord(w *Word) {
if
_
,
isExist
:=
brandMap
[
w
.
Keyword
];
isExist
{
w
.
IsBrand
=
true
usedMap
.
Store
(
w
.
Keyword
+
BRAND_TYPE
,
true
)
usedMap
.
Store
(
w
.
Keyword
,
true
)
}
if
_
,
isExist
:=
manualMap
[
w
.
Keyword
];
isExist
{
w
.
IsManual
=
true
w
.
ManualValue
=
manualMap
[
w
.
Keyword
]
usedMap
.
Store
(
w
.
Keyword
+
MANUAL_TYPE
,
true
)
usedMap
.
Store
(
w
.
Keyword
,
true
)
}
if
_
,
isExist
:=
categoryMap
[
w
.
Keyword
];
isExist
{
w
.
IsCategory
=
true
usedMap
.
Store
(
w
.
Keyword
+
CATEGORY_TYPE
,
true
)
usedMap
.
Store
(
w
.
Keyword
,
true
)
}
if
_
,
isExist
:=
sensitiveMap
[
w
.
Keyword
];
isExist
{
...
...
product/suggest-task.go
View file @
6249c39b
...
...
@@ -44,10 +44,6 @@ type Word struct {
WordRank
float64
`json:"wordRank"`
KeywordVersion
string
`json:"keywordVersion"`
}
const
BRAND_TYPE
=
"1"
const
CATEGORY_TYPE
=
"2"
const
MANUAL_TYPE
=
"3"
var
wordMap
sync
.
Map
var
brandMap
=
make
(
map
[
string
]
int
)
var
categoryMap
=
make
(
map
[
string
]
int
)
...
...
@@ -109,30 +105,25 @@ func main() {
}
func
checkUnusedData
(
bulkProcessor
*
elastic
.
BulkProcessor
)
{
var
tmpMap
=
make
(
map
[
string
]
bool
)
for
brand
:=
range
brandMap
{
if
_
,
exist
:=
usedMap
.
Load
(
brand
+
BRAND_TYPE
);
!
exist
{
addWord
(
brand
,
bulkProcessor
,
BRAND_TYPE
)
}
tmpMap
[
brand
]
=
true
;
}
for
category
:=
range
categoryMap
{
if
_
,
exist
:=
usedMap
.
Load
(
category
+
CATEGORY_TYPE
);
!
exist
{
addWord
(
category
,
bulkProcessor
,
CATEGORY_TYPE
)
}
tmpMap
[
category
]
=
true
}
for
manual
:=
range
manualMap
{
if
_
,
exist
:=
usedMap
.
Load
(
manual
+
MANUAL_TYPE
);
!
exist
{
addWord
(
manual
,
bulkProcessor
,
MANUAL_TYPE
)
tmpMap
[
manual
]
=
true
}
for
word
:=
range
tmpMap
{
if
_
,
exist
:=
usedMap
.
Load
(
word
);
!
exist
{
addWord
(
word
,
bulkProcessor
)
}
}
}
func
addWord
(
keyword
string
,
processor
*
elastic
.
BulkProcessor
,
wordType
string
)
{
var
w
=
new
(
Word
)
switch
wordType
{
case
BRAND_TYPE
:
w
.
IsBrand
=
true
case
CATEGORY_TYPE
:
w
.
IsCategory
=
true
case
MANUAL_TYPE
:
{
w
.
IsManual
=
true
;
w
.
ManualValue
=
manualMap
[
keyword
]}
}
w
.
Keyword
=
keyword
w
.
KeywordVersion
=
dateStr
processWord
(
w
)
...
...
@@ -322,18 +313,18 @@ func processWord(w *Word) {
if
_
,
isExist
:=
brandMap
[
w
.
Keyword
];
isExist
{
w
.
IsBrand
=
true
usedMap
.
Store
(
w
.
Keyword
+
BRAND_TYPE
,
true
)
usedMap
.
Store
(
w
.
Keyword
,
true
)
}
if
_
,
isExist
:=
manualMap
[
w
.
Keyword
];
isExist
{
w
.
IsManual
=
true
w
.
ManualValue
=
manualMap
[
w
.
Keyword
]
usedMap
.
Store
(
w
.
Keyword
+
MANUAL_TYPE
,
true
)
usedMap
.
Store
(
w
.
Keyword
,
true
)
}
if
_
,
isExist
:=
categoryMap
[
w
.
Keyword
];
isExist
{
w
.
IsCategory
=
true
usedMap
.
Store
(
w
.
Keyword
+
CATEGORY_TYPE
,
true
)
usedMap
.
Store
(
w
.
Keyword
,
true
)
}
if
_
,
isExist
:=
sensitiveMap
[
w
.
Keyword
];
isExist
{
...
...
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