我想在弹性搜索中使用更像这个查询来查找类似的文档.但是,我需要过滤执行查询的文档.
示例如下:我想查找类似于博客ID为123456但由作者120或作者123编写的博客项目.
执行此查询时,我从所有作者那里收回类似的博客,因此不会过滤...
{
"query":{
"more_like_this" : {
"fields" : ["body" ],
"docs" : [
{
"_id" : "123456"
}
],
"percent_terms_to_match" : 0.4,
"min_term_freq" : 1
}
}
},
"filter":{
"and":[
{
"type":{ "value":"blog" }
},
{
"terms":{ "authorId": ["120", "123"] }
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
Bla*_*POP 18
尝试过滤查询,如下所示:
{
"query": {
"filtered": {
"query": {
"more_like_this": {
"fields": [
"body"
],
"docs": [
{
"_id": "123456"
}
],
"percent_terms_to_match": 0.4,
"min_term_freq": 1
}
},
"filter": {
"and": [
{
"type": {
"value": "blog"
}
},
{
"terms": {
"authorId": [
"120",
"123"
]
}
}
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你...!
| 归档时间: |
|
| 查看次数: |
6190 次 |
| 最近记录: |