[英]ElasticSearch: more_like_this query
I have an index = "es_demo", where I need to find similar documents to given "_id", I don't think it is working as the returned results have same "_id" as mentioned in the query.我有一个索引 =“es_demo”,我需要在其中找到与给定“_id”相似的文档,我认为它不起作用,因为返回的结果与查询中提到的“_id”相同。 And as written in the elastic documentation having "include" parameter as "false" will not be returning the "ids" mentioned in the query.
正如弹性文档中所写,将“include”参数设置为“false”将不会返回查询中提到的“ids”。
{
"query": {
"more_like_this": {
"fields": "_doc",
"like": {
"docs": [
{
"_id": "5fac83afdce931230ef44c0a"
},
{
"_id": "5f80096adce931230e8bdb2d"
}
]
}
}
},
"include": "false"
}
Can someone please help me out here I think the query I wrote is wrong.有人可以帮我吗我认为我写的查询是错误的。
I also tried these queries:我也试过这些查询:
{
"query": {
"more_like_this": {
"fields": "_doc",
"like": [
{
"_id": "5fac83afdce931230ef44c0a"
},
{
"_id": "5f80096adce931230e8bdb2d"
}
]
}
}
}
{
"query": {
"more_like_this": {
"fields": "_doc",
"like": [
{
"_id": "5fac83afdce931230ef44c0a"
},
{
"_id": "5f80096adce931230e8bdb2d"
}
]
}
},
"include": "False"
}
The first result I got was the same document with "_id": "5fac83afdce931230ef44c0a" for every query我得到的第一个结果是同一个文档,每个查询都有“_id”:“5fac83afdce931230ef44c0a”
The query below works for my index movies.下面的查询适用于我的索引电影。
Remember about parameter fields:记住参数字段:
A list of fields to fetch and analyze the text from.
要从中获取和分析文本的字段列表。 Defaults to the index.query.default_field index setting, which has a default value of *.
默认为 index.query.default_field 索引设置,其默认值为 *。 The * value matches all fields eligible for term-level queries, excluding metadata fields.
* 值匹配所有符合术语级查询条件的字段,不包括元数据字段。
Query (edit for you case)查询(为你的案例编辑)
GET idx_movies/_search
{
"_source": [
"title"
],
"query": {
"more_like_this": {
"fields": [
"title", "description"
],
"like": [
{
"_id": "GjP1WYUBQB-6H-4Z96IG"
}
],
"min_term_freq":1
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.