Reputation: 31
I have an index on Algolia that have items like this one:
objectID: 1
name:"Universidade Estadual Paulista Júlio de Mesquita Filho"
acronym:"UNESP"
type:"level1"
aliases:[]
edited_by_admin:"1"
orderString:"UniversidadeEst..."
Almost all indexes have the edited_by_admin property as "0" and less than a half have this property set to "1".
I would like to know if there is a way to force the search using typeahead to search only over items that have the property edited_by_admin set to "1".
I need this since users with certain permissions can only search on items with edited_by_admin = 1 while admins can search over all results and I would like to use the same index for both.
Thanks in advance!
Upvotes: 1
Views: 142
Reputation: 31
I ended up finding the answer myself.
You have to set the property you want to filter as a facet on your index settings and then set it on typeahead like this:
$('...').typeahead(
{
hint: false,
minLength: 1
},
{
source: index.ttAdapter({
facetFilters: 'edited_by_admin:1',
hitsPerPage: 100
}),
displayKey: 'name',
templates: {
...
}
});
Upvotes: 2