我在按标签查询相关内容方面遇到了一些困难,并确保内容与至少X个标签相匹配。
例如,在"案例研究"在案例研究内容下面,应提供链接以链接到其他相关案例研究。但是,另一个页面(例如产品页面)可能会有一些类似的标签,并且当它不相关时会显示为相关标签。只有案例研究才能出现在该区块内。
到目前为止,我已经构建了查询以根据标记检索相关内容,但我仍然坚持定义必须存在的标记。
以下是我的基础' more_like_this'查询:
{
"query": {
"more_like_this": {
"ids": [22],
"fields": ["tags"],
"min_doc_freq": 1,
"min_term_freq": 1
}
},
"fields": ["tags", "title", "id"]
}
以下是我到目前为止关于定义所需标签的内容:
{
"query": {
"filtered": {
"query": {
"more_like_this": {
"ids": [
22
],
"fields": [
"tags"
],
"min_doc_freq": 1,
"min_term_freq": 1
}
},
"filter": {
"term": {
"tag": "Case Study"
}
}
}
}
}
不幸的是,这只提供了0次点击:/
示例文档如下所示:
{
_index: tags
_type: page
_id: 21
_version: 1
_score: 1
_source: {
id: 21
title: Why a Printing Company uses our CMS
tags: [
Case Study
Case Study
CMS
Printing
]
path: /case-study/why-a-printing-company-uses-our-cms
updatedAt: {
date: 2014-09-18 10:57:46.000000
timezone_type: 3
timezone: Europe/London
}
}
}
(从Head插件粘贴的副本,因此不是有效的JSON)
感谢您的帮助。