unflores
unflores

Reputation: 1810

How do I limit the result attributes coming back from algolia?

When I use algolia's instantsearch, the url that I hit returns all the attributes for the object that is hit. I have multiple different types of users and I don't want to just display something like a user's email to the entire world. Is there a way to query algolia differently so that I can limit the returned resultset before it comes to the page?

My current idea is to funnel everything through the our backend but I don't like the idea of limiting the spead of my search results by my own server response speed.

Here's an example of the algolia hit that returns all of my keys:

https://identifier-dsn.algolia.net/1/indexes/localhost_users/query?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%203.18.0&x-algolia-application-id=identifier&x-algolia-api-key=secret_letters

Upvotes: 1

Views: 728

Answers (1)

Guy Daher
Guy Daher

Reputation: 5601

For better control over what kind of data is returned, you can configure the attributesToRetrieve and attributesToHighlight of your index. Take a look at the documentation for the attributesToRetrieve here.

Edit: Also, use unretrievableAttributes if you want don't want someone with a Search API key to get access to some attributes

Upvotes: 2

Related Questions