Hi I’m implementing a search feature on my app and the team decided to use algolia and it fits how we want our functionality to work, but one thing is missing the negation (fetching all records that doesn’t contain the given keyword e.g “dream” result all records that doesn’t contain the word “dream”.
I think you’re looking for our
Even if you don’t asked for multi-word negation, I don’t think we support mixing negation and quoted expressions though.
I’ve test negation and quoted expression and they work both together, the only issue I have with negation is doesn’t fetch all records “that does not have the negated word” which is a requirement to my search feature.
Indeed, this is a feature which won’t work with an empty query, I’m sorry about the confusion here.
The correct solution here, even if definitely not perfect, would be to index all of your words in an array attribute and use facet excludes (
NOT syntax) at query time : https://www.algolia.com/doc/api-reference/api-parameters/filters/ .
The reason for this limitation is that we have to ensure that the amount of objects we exclude the word from is not too big. In the case of an empty query, this means we have to go through every record of the index to check if the word is there or not. We do have a timeout there, and it’s likely to be hit on a big and full index.
I do have a question though: what are you trying to achieve here? In this case, it seems like what you’re trying to do would be a better fit for a DB query.
Okay thanks!, well our search feature has complex customized feature, We have tried using DB query but not really helpful and the results are inaccurate. I think the only solution I see is to make the keyword field a requirement before making the other filter available for use.
This would indeed work. I’m sorry to have to force this constraint on you!