Hi everyone,
I am trying to use the new moreLikeThis operator and encountered some behaviour that I cannot explain. I have an Atlas search index on a books collection that includes title, authors, genres, etc. I am using Atlas search for recommendations whenever an exact match cannot be found (given other criteria such as postcode, distance, city, etc.). I noticed that whenever the search term is encountered only once in the relevant field in my collection, I get 0 moreLikeThis results back. If it is more than once, then I get results. For example, for a search like this I get 0 results back since I have only 1 book by Frank Tallis.
[{
"$search": {
"index": "bookSearchIndex",
"compound": {
"must": [
{
"moreLikeThis": {
"like": [
{
authors: ["Frank"]
}
]
}
}
]
}
}
}
]
The explain() for above is:
"explain": {
"path": "compound.must",
"type": "DefaultQuery",
"args": {
"queryType": "MatchNoDocsQuery"
}
}
When I search for a term that is encountered at least twice in the collection, I get results. For example:
[{
"$search": {
"index": "bookSearchIndex",
"compound": {
"must": [
{
"moreLikeThis": {
"like": [
{
authors: ["Donna"]
}
]
}
}
]
}
}
}
]
I have two books, each by a different author with the first name Donna. The explain() for above is:
"explain": {
"path": "compound.must",
"type": "TermQuery",
"args": {
"path": "authors",
"value": "donna"
}
}
This behaviour repeats across other fields (like title). I have two books: “Prisoner of Azkaban” and “Prisoners of Geogrpahy”. If I search under “prisoner”, I get recommendations, but 0 recommendations if I search under ‘geography’. Is it that the algorithm does not index/take into account terms that are encountered only once in the collection? If that is the case, I am better off using the “should” compound operator.
Many thanks for any explanations/advice.
Kind regards,
Gueorgui