Reputation: 1
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 . And as written in the elastic documentation having "include" parameter as "false" will not be returning the "ids" mentioned in the query.
{
"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
Upvotes: 0
Views: 40
Reputation: 3271
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 *. 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
}
}
}
Upvotes: 0