Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
a4759e13
Commit
a4759e13
authored
Nov 11, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
48c8c566
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
40 deletions
+43
-40
es_tool.py
eda/smart_rank/es_tool.py
+42
-0
gm_feed_cold_start.py
eda/smart_rank/gm_feed_cold_start.py
+1
-1
tool.py
eda/smart_rank/tool.py
+0
-39
No files found.
eda/smart_rank/es_tool.py
0 → 100644
View file @
a4759e13
from
elasticsearch
import
Elasticsearch
as
Es
def
get_es
():
init_args
=
{
'sniff_on_start'
:
False
,
'sniff_on_connection_fail'
:
False
,}
new_hosts
=
[{
'host'
:
'172.16.31.17'
,
'port'
:
9000
},
{
'host'
:
'172.16.31.11'
,
'port'
:
9000
},
{
'host'
:
'172.16.31.13'
,
'port'
:
9000
}]
new_es
=
Es
(
hosts
=
new_hosts
,
**
init_args
)
return
new_es
def
es_index_adapt
(
index_prefix
,
doc_type
,
rw
=
None
):
"""get the adapted index name
"""
assert
rw
in
[
None
,
'read'
,
'write'
]
index
=
'-'
.
join
((
index_prefix
,
doc_type
))
if
rw
:
index
=
'-'
.
join
((
index
,
rw
))
return
index
def
es_query
(
doc
,
body
,
offset
,
size
,
es
=
None
):
if
es
is
None
:
es
=
get_es
()
index
=
es_index_adapt
(
index_prefix
=
'gm-dbmw'
,
doc_type
=
doc
,
rw
=
'read'
)
res
=
es
.
search
(
index
=
index
,
doc_type
=
doc
,
timeout
=
'10s'
,
body
=
body
,
from_
=
offset
,
size
=
size
)
return
res
def
es_mquery
(
doc
,
body
,
es
=
None
):
if
es
is
None
:
es
=
get_es
()
index
=
es_index_adapt
(
index_prefix
=
'gm-dbmw'
,
doc_type
=
doc
,
rw
=
'read'
)
res
=
es
.
msearch
(
body
,
index
=
index
)
return
res
\ No newline at end of file
eda/smart_rank/gm_feed_cold_start.py
View file @
a4759e13
import
redis
import
json
from
tool
import
es_query
from
es_
tool
import
es_query
from
tool
import
get_data_by_mysql
...
...
eda/smart_rank/tool.py
View file @
a4759e13
...
...
@@ -13,7 +13,6 @@ import time
import
json
import
numpy
as
np
import
pandas
as
pd
from
elasticsearch
import
Elasticsearch
as
Es
def
send_email
(
app
,
id
,
e
):
...
...
@@ -350,41 +349,3 @@ def get_user_log(cl_id, all_word_tags, pay_time=0, debug=0):
return
user_df_service
def
get_es
():
init_args
=
{
'sniff_on_start'
:
False
,
'sniff_on_connection_fail'
:
False
,}
new_hosts
=
[{
'host'
:
'172.16.31.17'
,
'port'
:
9000
},
{
'host'
:
'172.16.31.11'
,
'port'
:
9000
},
{
'host'
:
'172.16.31.13'
,
'port'
:
9000
}]
new_es
=
Es
(
hosts
=
new_hosts
,
**
init_args
)
return
new_es
def
es_index_adapt
(
index_prefix
,
doc_type
,
rw
=
None
):
"""get the adapted index name
"""
assert
rw
in
[
None
,
'read'
,
'write'
]
index
=
'-'
.
join
((
index_prefix
,
doc_type
))
if
rw
:
index
=
'-'
.
join
((
index
,
rw
))
return
index
def
es_query
(
doc
,
body
,
offset
,
size
,
es
=
None
):
if
es
is
None
:
es
=
get_es
()
index
=
es_index_adapt
(
index_prefix
=
'gm-dbmw'
,
doc_type
=
doc
,
rw
=
'read'
)
res
=
es
.
search
(
index
=
index
,
doc_type
=
doc
,
timeout
=
'10s'
,
body
=
body
,
from_
=
offset
,
size
=
size
)
return
res
def
es_mquery
(
doc
,
body
,
es
=
None
):
if
es
is
None
:
es
=
get_es
()
index
=
es_index_adapt
(
index_prefix
=
'gm-dbmw'
,
doc_type
=
doc
,
rw
=
'read'
)
res
=
es
.
msearch
(
body
,
index
=
index
)
return
res
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