Open sritchie926 opened 6 years ago
I'd say that it is working as implemented, though clearly not as expected 😉
I'm guessing for your search you are then not seeing any results because it is not possible that the category is both 'Fruit' and 'Vegetables' at the same time?
Currently there is no built-in support for grouping of query terms. If you drop the '+' (presence required) operator from those categories you will get close to what you want, but you will also see results for any category, though they will have lower rank. Alternatively you could split this into two queries (status:2 +category:Fruit
and status:2 +category:Vegetable
) and combine the results yourself in your application code.
Supporting these kind of queries is something that I would like to eventually add to Lunr, I just don't know when that will be.
I am using the lunr search to add filters to a list and I am using the syntax for a logical AND, though I had expected search terms with the same field to be ORed.
Example:
idx.search("+status:2 +category:Fruit +category:Vegetables")
Should end up as:
status:2 AND (category:Fruit OR category:Vegetables)
But it's actually ending up as
status:2 AND category:Fruit AND category:Vegetables
Is this a bug or the expected functionality? If this is the expected functionality, is there different syntax I can use to achieve this?