How can I get all the tags
attribute and group by distinct as circled in the provided image? Each record may have tags and the tags may duplicates. I’ve tried to get this data by using the JavaScript API as seen below and it didn’t work. I expect it to show all the unique tags as circled but instead, it returns every record. Any idea on how to achieve the desired outcomes?
import algoliasearch from "algoliasearch";
const algoliaClient = algoliasearch(
process.env.VUE_APP_ALGOLIA_APP_ID,
process.env.VUE_APP_ALGOLIA_ADMIN_KEY
);
const algoliaIndex = algoliaClient.initIndex("main-index");
algoliaIndex.setSettings({
attributeForDistinct: "tags",
attributesToRetrieve: ["tags"],
distinct: 1
});
algoliaIndex.search().then(({ hits }) => {
console.log(hits);
});