def _build_post_data(self, keywords: List[str] = None):
query = {
"sort": [
{
"publish_time_str": {
"order": "desc"
}
},
{
"read_count": {
"order": "desc"
}
}
],
"size": 10
}
if keywords:
query["query"] = {
"bool": {
"must": [
{
"range": {
"publish_time_str": {"from": "2020-08-01 00:00:00",
"to": "2020-08-06 23:00:00"}
}
},
{
"bool": {
"should": [
]
}
}
]
}
}
should = query["query"]["bool"]["must"][1]["bool"]["should"]
for keyword in keywords:
match = {"match_phrase": {
"title": keyword
}}
should.append(match)
return json.dumps(query)
网友评论