Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cybertron
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpha
cybertron
Commits
66ffbe75
Commit
66ffbe75
authored
Jul 16, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
21f9e748
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
171 deletions
+6
-171
workspace.xml
.idea/workspace.xml
+0
-0
pictorial.py
index_contrast/pictorial.py
+0
-0
tag.py
index_contrast/tag.py
+6
-171
user.py
index_contrast/user.py
+0
-0
No files found.
.idea/workspace.xml
View file @
66ffbe75
This diff is collapsed.
Click to expand it.
index_contrast/pictorial.py
View file @
66ffbe75
This diff is collapsed.
Click to expand it.
index_contrast/tag.py
View file @
66ffbe75
...
...
@@ -18,7 +18,6 @@ ES_INFO_LIST = [
]
ES_INDEX_PREFIX
=
"gm-dbmw"
class
ESPerform
(
object
):
cli_obj
=
None
cli_info_list
=
ES_INFO_LIST
...
...
@@ -190,8 +189,8 @@ class ESPerform(object):
try
:
assert
(
es_cli
is
not
None
)
official_index_name
=
sub_index_name
if
sub_index_name
!=
"mv-alpha-tag
-test-190711901"
:
official_index_name
=
cls
.
get_official_index_name
(
sub_index_name
,
"read"
)
# if sub_index_name != "mv-alpha-user
-test-190711901":
#
official_index_name = cls.get_official_index_name(sub_index_name, "read")
index_exists
=
es_cli
.
indices
.
exists
(
official_index_name
)
if
not
index_exists
:
...
...
@@ -236,13 +235,13 @@ class ESPerform(object):
try
:
assert
(
es_cli
is
not
None
)
official_index_name
=
cls
.
get_official_index_name
(
sub_index_name
,
"read"
)
index_exists
=
es_cli
.
indices
.
exists
(
official
_index_name
)
#
official_index_name = cls.get_official_index_name(sub_index_name, "read")
index_exists
=
es_cli
.
indices
.
exists
(
sub
_index_name
)
if
not
index_exists
:
logging
.
error
(
"index:
%
s is not existing,get_search_results error!"
%
official
_index_name
)
logging
.
error
(
"index:
%
s is not existing,get_search_results error!"
%
sub
_index_name
)
return
None
res
=
es_cli
.
indices
.
analyze
(
index
=
official
_index_name
,
body
=
query_body
)
res
=
es_cli
.
indices
.
analyze
(
index
=
sub
_index_name
,
body
=
query_body
)
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
@@ -284,170 +283,6 @@ class ESPerform(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
True
@classmethod
def
get_tag_topic_list
(
cls
,
tag_id
,
have_read_topic_id_list
,
size
=
100
):
try
:
functions_list
=
list
()
# for id in tag_id:
# functions_list.append(
# {
# "filter": {"term": {"tag_list": id}},
# "weight": 1
# }
# )
functions_list
+=
[
{
"filter"
:
{
"constant_score"
:
{
"filter"
:
{
"term"
:
{
"content_level"
:
6
}}
}
},
"weight"
:
60
},
{
"filter"
:
{
"constant_score"
:
{
"filter"
:
{
"term"
:
{
"content_level"
:
5
}}
}
},
"weight"
:
50
},
{
"filter"
:
{
"constant_score"
:
{
"filter"
:
{
"term"
:
{
"content_level"
:
4
}}
}
},
"weight"
:
40
}
]
q
=
{
"query"
:
{
"function_score"
:
{
"query"
:
{
"bool"
:
{
"must"
:
[
{
"range"
:
{
"content_level"
:
{
"gte"
:
4
,
"lte"
:
6
}}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"terms"
:
{
"tag_list"
:
tag_id
}}
]
}
},
"boost_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
"functions"
:
functions_list
}
},
"_source"
:
{
"include"
:
[
"id"
]
},
"sort"
:
[
{
"_score"
:
{
"order"
:
"desc"
}},
{
"create_time_val"
:
{
"order"
:
"desc"
}},
# {"language_type": {"order": "asc"}},
]
}
if
len
(
have_read_topic_id_list
)
>
0
:
q
[
"query"
][
"function_score"
][
"query"
][
"bool"
][
"must_not"
]
=
{
"terms"
:
{
"id"
:
have_read_topic_id_list
}
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic"
,
query_body
=
q
,
offset
=
0
,
size
=
size
,
routing
=
"4,5,6"
)
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
logging
.
info
(
"topic_id_list:
%
s"
%
str
(
topic_id_list
))
return
topic_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
@classmethod
def
get_tag_topic_list_dict
(
cls
,
tag_id
,
have_read_topic_id_list
,
size
=
100
):
try
:
functions_list
=
list
()
for
id
in
tag_id
:
functions_list
.
append
(
{
"filter"
:
{
"term"
:
{
"tag_list"
:
id
}},
"weight"
:
1
}
)
# functions_list += [
# {
# "filter": {"term": {"content_level": 6}},
# "weight": 6000
# },
# {
# "filter": {"term": {"content_level": 5}},
# "weight": 5000
# },
# {
# "filter": {"term": {"content_level": 4}},
# "weight": 4000
# }
# ]
q
=
{
"query"
:
{
"function_score"
:
{
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"content_level"
:
6
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"terms"
:
{
"tag_list"
:
tag_id
}}
]
}
},
"boost_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
"functions"
:
functions_list
}
},
"_source"
:
{
"include"
:
[
"id"
,
"user_id"
]
},
"sort"
:
[
{
"_score"
:
{
"order"
:
"desc"
}},
{
"create_time_val"
:
{
"order"
:
"desc"
}},
{
"language_type"
:
{
"order"
:
"asc"
}},
],
"collapse"
:
{
"field"
:
"user_id"
}
}
if
len
(
have_read_topic_id_list
)
>
0
:
q
[
"query"
][
"function_score"
][
"query"
][
"bool"
][
"must_not"
]
=
{
"terms"
:
{
"id"
:
have_read_topic_id_list
}
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic-high-star"
,
query_body
=
q
,
offset
=
0
,
size
=
size
,
routing
=
"6"
)
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
# logging.info("topic_id_list:%s" % str(topic_id_list))
# topic_id_dict = [{str(item["_source"]["id"]):item["_source"]["user_id"]} for item in result_dict["hits"]]
topic_id_dict
=
dict
()
for
item
in
result_dict
[
"hits"
]:
topic_id_dict
[
str
(
item
[
"_source"
][
"id"
])]
=
item
[
"_source"
][
"user_id"
]
logging
.
info
(
"topic_id_list:
%
s"
%
str
(
topic_id_dict
))
return
topic_id_list
,
topic_id_dict
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
# 先获取一部分数据
es_cli_obj
=
ESPerform
.
get_cli
()
...
...
index_contrast/user.py
View file @
66ffbe75
This diff is collapsed.
Click to expand it.
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