Hi guys ,
Im trying to set my querie suggestion index for my project so I can add categories to
autocomplete searchbox.
I already have my posts_index that represents my articles for sail.
This is a document example
{
"title": "Bici",
"country_code": "AR",
"description": "vendo todo",
"tags": [],
"price": 0,
"negotiable": null,
"contact_name": "Leostereo",
"created_at": "2022-02-03T12:41:22.000000Z",
"created_at_str": "Feb 3, 2022",
"updated_at": "2022-02-03T12:41:22.000000Z",
"url": "http://172.30.200.117/bici/144",
"category": "Tools & Accessories",
"parent_category": "Beauty & Well being",
}
Then I according to this do:
click on Query Suggestions on the left side → new Querie Suggestion Index.
I used the default names , so it begin building the “posts_index_query_suggestions”
First question:
When it finished building the index , I have 2 records , with no any related data.
Why there are 2 records ?? what are the based on?
I can also view those options bellow my autocomplete box , but they have no sense for me.
Then going inside the posts_index_query_suggestions , I scroll down to categories.
chick → Edit Categories and add the “category” attribute wich I marked as faceting
on my posts_index as filter_only.
Then , when trying to implement this:
const appId = 'latency';
const apiKey = '6be0576ff61c053d5f9a3225e2a90f76';
const searchClient = algoliasearch(appId, apiKey);
const querySuggestionsPlugin = createQuerySuggestionsPlugin({
searchClient,
indexName: 'instant_search_demo_query_suggestions',
getSearchParams({ state }) {
return { hitsPerPage: state.query ? 5 : 10 };
},
categoryAttribute: [
'instant_search',
'facets',
'exact_matches',
'categories',
],
itemsWithCategories: 2,
categoriesPerItem: 2,
});
autocomplete({
container: '#autocomplete',
plugins: [querySuggestionsPlugin],
openOnFocus: true,
});
It works with proposed index but it does not work with my index.
It seems I need to setup more things on my algolia project side.
Whats the minimun settup requiered to in order to only use the “category” attribute from my posts_index ?
Is there some way to access and analize the index used for this example ?
Is there some usefull doc/video to follow ?
Would you please help me?
Leandro.