Return only attributes

Is there a way to call a search to return only the attributes for example, if i have a facet: movies and in it are the genres, action, adventure etc… i want to return a list of those, just the action, adventure and not the records pertaining to each of them.

so something like: except not the hits.

index.search({
  facets: ['movies']
});
1 Like

Hi @nritsonsa,

I think what you are looking for is the “search for facet values” feature.

Here is the documentation: https://www.algolia.com/doc/guides/searching/faceting/?language=php#search-for-facet-values

Let me know if that is not what you were looking for,

Cheers,

you can use attributesToRetrieve, it’ll restrict what you search to only those attributes. It’s also an index setting if you want to have this always

but this still brings back duplicates, for example with this method, if 3 records were ‘action’ it means i will get back 3 hits with ‘action’ i want to print out just 1 copy of the attribute list.

Hmm, seems you meant something else than I thought what you meant then, did you check out DISTINCT? https://www.algolia.com/doc/guides/ranking/distinct/

tried

attributesToRetrieve: ['publishers'],
page: callPage,

still returning duplicates, im guessing this is working off the ObjectID as the key for it whereas i need it to look at the attributes

I’m not exactly sure what you mean with duplicates, but you probably mean distinct

Oh I’m totally sorry, I completely read something else than what you asked. Does https://community.algolia.com/instantsearch.js/v2/widgets/refinementList.html help you? You can use refinementList instead of hits

not quite sure that works, i have something like this: img
and i want to make an algolia call to fetch me only the names action, indie etc from the genres. then im going to display those names as text on the site. i thought there was a call that would return an object like { genres: “action, adventure, indie” }

Is that the complete search interface or is there also a complete search? Could you explain why that’s different to a custom rendered menu or refinement list?