我想应用more like this查询,所以我使用这个(elasticsearch的python包装器):
{
"query": {
"more_like_this": {
"fields": ["title", "content"],
"docs": [
{
"_index": "kavosh",
"_type": "articles",
"_id": str(news_id)
}
]
}
},
"size": 1,
}但我有很多超时时间。所以我决定把mlt检查的范围缩小到一个星期。(有效吗?)例如,添加以下内容:
{
"range": {
"publication_date": {
"lte": now,
"gte": now - 1week
}
}
}如何将此过滤器应用于MLT查询,您有什么建议来优化查询吗?
发布于 2016-01-29 17:23:05
您可以使用以下查询:
{
"query": {
"filtered": {
"query": {
"more_like_this": {
"fields": [
"title",
"content"
],
"docs": [
{
"_index": "kavosh",
"_type": "articles",
"_id": str(news_id)
}
]
}
},
"filter": {
"range": {
"publication_date": {
"lte": "now",
"gte": "now - 1week"
}
}
}
}
}
}希望能帮上忙。
https://stackoverflow.com/questions/35090031
复制相似问题