|
@@ -2,7 +2,7 @@ import bson
|
|
import pymongo
|
|
import pymongo
|
|
import redis
|
|
import redis
|
|
from elasticsearch import Elasticsearch
|
|
from elasticsearch import Elasticsearch
|
|
-
|
|
|
|
|
|
+from utils.title_participle import get_should
|
|
from config.load import mongo_conf, redis_conf, es_conf
|
|
from config.load import mongo_conf, redis_conf, es_conf
|
|
|
|
|
|
# ---------------------------------- mongo ----------------------------------
|
|
# ---------------------------------- mongo ----------------------------------
|
|
@@ -65,20 +65,16 @@ def es_query(title: str, publish_time: int):
|
|
client = es_client()
|
|
client = es_client()
|
|
stime = publish_time - 432000 # 往前推5天
|
|
stime = publish_time - 432000 # 往前推5天
|
|
etime = publish_time + 432000
|
|
etime = publish_time + 432000
|
|
|
|
+
|
|
|
|
+ time_limit = {"range": {'publishtime': {"from": stime, "to": etime}}}
|
|
|
|
+ should_list = get_should(title) # 对标题进行分词组合query语句
|
|
# 通过发布标题和发布时间范围查询
|
|
# 通过发布标题和发布时间范围查询
|
|
query = {
|
|
query = {
|
|
"query": {
|
|
"query": {
|
|
"bool": {
|
|
"bool": {
|
|
- "must": [
|
|
|
|
- {
|
|
|
|
- "multi_match": {
|
|
|
|
- "query": title,
|
|
|
|
- "type": "phrase",
|
|
|
|
- "fields": ["title"]
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {"range": {'publishtime': {"from": stime, "to": etime}}}
|
|
|
|
- ]
|
|
|
|
|
|
+ "must": [time_limit],
|
|
|
|
+ "should": should_list,
|
|
|
|
+ "minimum_should_match": "10<90%",
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|