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
3db822c1
Commit
3db822c1
authored
Oct 29, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
a66215bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
144 additions
and
122 deletions
+144
-122
es_tag.py
es_tag.py
+144
-122
No files found.
es_tag.py
View file @
3db822c1
...
...
@@ -56,7 +56,7 @@ def es_query(doc, body, offset, size, es=None):
from_
=
offset
,
size
=
size
)
number
=
res
[
"hits"
][
"total"
]
or
0
number
=
res
[
"hits"
][
"total"
]
return
number
...
...
@@ -424,13 +424,13 @@ def answer():
tmp
.
append
(
es_query
(
'answer'
,
video_star5_q
,
0
,
1
))
total_list
.
append
(
tmp
)
print
(
i
)
print
(
tmp
)
#
print(i)
#
print(tmp)
df
=
pd
.
DataFrame
(
total_list
)
df
=
df
.
rename
(
columns
=
{
0
:
"tag"
,
1
:
"star_3"
,
2
:
"star_4"
,
3
:
"star_5"
,
4
:
"video_star_3"
,
5
:
"video_star_4"
,
6
:
"video_star_5"
})
df
.
to_csv
(
"/home/gmuser/answer.csv"
,
index
=
False
)
df
.
to_csv
(
"/home/gmuser/answer.csv"
,
index
=
False
,
encoding
=
"utf_8_sig"
)
def
question
():
...
...
@@ -617,14 +617,13 @@ def question():
for
i
in
tags
:
tmp
=
[
i
]
query
=
i
# TODO 下面两个q语句
q
=
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"
desc^1"
,
"answer
^1"
],
"fields"
:
[
"title^1"
,
"
content^1"
,
"tags
^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
...
...
@@ -649,7 +648,7 @@ def question():
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"
desc^1"
,
"answer
^1"
],
"fields"
:
[
"title^1"
,
"
content^1"
,
"tags
^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
...
...
@@ -672,12 +671,12 @@ def question():
tmp
.
append
(
es_query
(
category
,
video_q
,
0
,
1
))
total_list
.
append
(
tmp
)
print
(
i
)
print
(
tmp
)
#
print(i)
#
print(tmp)
df
=
pd
.
DataFrame
(
total_list
)
df
=
df
.
rename
(
columns
=
{
0
:
"tag"
,
1
:
"number"
,
2
:
"video_number"
})
df
.
to_csv
(
"/home/gmuser/question.csv"
,
index
=
False
)
df
.
to_csv
(
"/home/gmuser/question.csv"
,
index
=
False
,
encoding
=
"utf_8_sig"
)
def
topic
():
...
...
@@ -871,7 +870,8 @@ def topic():
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"desc^1"
,
"answer^1"
],
"fields"
:
[
"content^1"
,
"author^1"
,
"tractate_tag_name^1"
,
"tractate_tag_name_content^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
...
...
@@ -883,7 +883,12 @@ def topic():
},
{
"term"
:
{
"content_level"
:
3
}
}]
},
{
"term"
:
{
"status"
:
"3"
}
}]
}
}
...
...
@@ -893,168 +898,185 @@ def topic():
tmp
.
append
(
es_query
(
category
,
star3_q
,
0
,
1
))
star4_q
=
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"desc^1"
,
"answer^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"content_level"
:
4
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"content^1"
,
"author^1"
,
"tractate_tag_name^1"
,
"tractate_tag_name_content^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
}]
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"content_level"
:
4
}
},
{
"term"
:
{
"status"
:
"3"
}
}]
}
}
}
}
}
tmp
.
append
(
es_query
(
category
,
star4_q
,
0
,
1
))
star5_q
=
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"desc^1"
,
"answer^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"content_level"
:
5
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"content^1"
,
"author^1"
,
"tractate_tag_name^1"
,
"tractate_tag_name_content^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
}]
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"content_level"
:
5
}
},
{
"term"
:
{
"status"
:
"3"
}
}]
}
}
}
}
}
tmp
.
append
(
es_query
(
category
,
star5_q
,
0
,
1
))
video_star3_q
=
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"desc^1"
,
"answer^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"is_video"
:
True
}
},
{
"term"
:
{
"content_level"
:
3
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"content^1"
,
"author^1"
,
"tractate_tag_name^1"
,
"tractate_tag_name_content^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
}]
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"content_level"
:
3
}
},
{
"term"
:
{
"status"
:
"3"
}
},
{
"term"
:
{
"is_video"
:
True
}}]
}
}
}
}
}
tmp
.
append
(
es_query
(
category
,
video_star3_q
,
0
,
1
))
video_star4_q
=
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"desc^1"
,
"answer^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"is_video"
:
True
}
},
{
"term"
:
{
"content_level"
:
4
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"content^1"
,
"author^1"
,
"tractate_tag_name^1"
,
"tractate_tag_name_content^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
}]
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"content_level"
:
4
}
},
{
"term"
:
{
"status"
:
"3"
}
},
{
"term"
:
{
"is_video"
:
True
}}]
}
}
}
}
}
tmp
.
append
(
es_query
(
category
,
video_star4_q
,
0
,
1
))
video_star5_q
=
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"title^1"
,
"desc^1"
,
"answer^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"is_video"
:
True
}
},
{
"term"
:
{
"content_level"
:
5
"query"
:
{
"filtered"
:
{
"filter"
:
{
"bool"
:
{
"must"
:
[{
"multi_match"
:
{
"fields"
:
[
"content^1"
,
"author^1"
,
"tractate_tag_name^1"
,
"tractate_tag_name_content^1"
],
"operator"
:
query_operator
,
"type"
:
query_type
,
"query"
:
query
}
}]
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"content_level"
:
5
}
},
{
"term"
:
{
"status"
:
"3"
}
},
{
"term"
:
{
"is_video"
:
True
}}]
}
}
}
}
}
tmp
.
append
(
es_query
(
category
,
video_star5_q
,
0
,
1
))
total_list
.
append
(
tmp
)
print
(
i
)
print
(
tmp
)
#
print(i)
#
print(tmp)
df
=
pd
.
DataFrame
(
total_list
)
df
=
df
.
rename
(
columns
=
{
0
:
"tag"
,
1
:
"star_3"
,
2
:
"star_4"
,
3
:
"star_5"
,
4
:
"video_star_3"
,
5
:
"video_star_4"
,
6
:
"video_star_5"
})
df
.
to_csv
(
"/home/gmuser/topic.csv"
,
index
=
False
)
df
.
to_csv
(
"/home/gmuser/topic.csv"
,
index
=
False
,
encoding
=
"utf_8_sig"
)
if
__name__
==
"__main__"
:
answer
()
topic
()
print
(
"topic"
)
question
()
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