Create a replica with a subset of data,, for example I want online_posts replica to show only the published posts

Hey there, I want to create a replica from my Posts index, to show only the published posts based on isPuplished attribute in every record, so Online posts only will be shown in the online_posts replica.

Hi @bdairy08,

Welcome to the Algolia Community!

You can use search filters on the isPublished attribute to filter only the published posts. You could use this feature without having to make a replica of your index.

You can find more information about filtering your records here:

If you need more secured features, such as filtering by users, you could use the Secured API Keys feature as explained here:

Let us know how this works for you!

Yes I know about filtering data,I am using tons of filters :slight_smile: but anyone can view my http request through dev tools, and change the filter and will get all the the data … So I guess that leaves me with the SecureAPiKeys option… Thanks for the help . I didn’t know they exist

@bdairy08 Let us know how the Secured API keys work for you!

In this example API keys | Algolia

var searchOnlyApiKey = 'BIEV2YG99YSHTKQXQM';
var params = {
  hitsPerPage: 20,
  filters: '_tags:user_42 AND available = 1',
  validUntil: currentTimestamp + 3600,
  restrictIndices: 'index1,index2',
  userToken: 'user_42',
  restrictSources: ''
var publicKey = client.generateSecuredApiKey(searchOnlyApiKey, params);

as in the documentation, the first line shows searchOnlyApiKey, which I assume that this is one that I can get from my dashboard… when . I use it i get this error

Unhandled error TypeError: Key must be a buffer
at new Hmac (crypto.js:117:16)
at Object.createHmac (crypto.js:643:10)

So from where we can get that key?

Hi bdairy08,

You can find the Search Only API on your dashboard:

If you are still getting the error, could you make a code sandbox with minimal code to replicate the error at ?

You can find starter codesandbox templates for each of our instantsearch clients here if that helps:

Best regards,

Thanks Cindy for the help, I did manage to generate the API key, and everything works like charm
I have one small question though;

these are my params

hitsPerPage: 20,
filters: ‘ OR’,
validUntil: 1562077780250,
restrictIndices: ‘online_properties, cities’

my main focus to get only values with status id = 4 , or 2…

status is object within every record that looks like this:

“status”: {
“id”: 2,
“nameEn”: “Pending Approval”

BUT Cities index has no status object, I just want to get it all, how can specify filter for only online_properties index… and no filters for cities index…

Again thanks a MILION

Any update on my last question?? :smiley:

It’s been a while since your last question, have you received the answer since then?