Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a user exclude a keyword in search results?

Tags:

algolia

For example, could they type "-Adventure" if they want results without the word adventure to appear in their search results?

like image 553
user128638 Avatar asked Mar 10 '23 10:03

user128638


1 Answers

Sure thing! You need to enable the advancedSyntax feature and then the - in front of words will be interpreted as a NOT.

index.search('Crazy -Adventure', { advancedSyntax: true }).then(...);

Will search all objects with Crazy and without Adventure.

like image 133
redox Avatar answered Apr 28 '23 08:04

redox