The documentation states that the path
needs to be a string
and not an array of strings. I just want to confirm that that is in fact the only possibility, and if, in either case, there is a recommended way to do this.
e.g. I want to search (with autocompletion) my movies for the text "hammer"
on both the title
and the plot
In the current scenario I can implement a search by either title
or plot
with ease. But If I try to do it for both, making path
an array of strings, which is acceptable on other operators, I get an error
If you are trying to match on title and plot, use should: in compound operator
create autocomplete search index on both fields : title and plot
$search: {
compound: {
should: [
{
autocomplete: {
query:'hammer',
path: 'title',
},
},
{
autocomplete: {
query:'hammer',
path: 'plot',
},
},
],
},
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With