Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: cannot apply the batch operation on a replica index #179

Open
lopandpe opened this issue Jul 19, 2023 · 0 comments
Open

Error: cannot apply the batch operation on a replica index #179

lopandpe opened this issue Jul 19, 2023 · 0 comments

Comments

@lopandpe
Copy link

Hi there!

Maybe We have configured it wrong, but when we build our gatsby application, 50% of times it throws the same error message:

ERROR  UNKNOWN

failed to index to Algolia cannot apply the batch operation on a replica index


  Error: cannot apply the batch operation on a replica index


not finished onPostBuild - 0.849s

failed index to Algolia - 0.849s - Found 1 stale objects; removing...

 ELIFECYCLE  Command failed with exit code 1.

We have to build again and then it works perfectly.

This is an example of how do we create the queries:

const queries = [
  {
    indexName: esIndexName,
    query: ActivitiesQuery,
    transformer: ({ data }: { data: ActivitiesResponse }) =>
      data.api.products.map(activityToAlgoliaRecord),
    settings: {
      attributesToSnippet: [`description:20`],
      attributesForFaceting: [...],
      searchableAttributes: [...],
      replicas: Object.values(replicas.es).map((value) => `virtual(${value})`),
    },
  },
  {
    indexName: replicas.es.PRICE_DESC,
    query: ActivitiesQuery,
    transformer: ({ data }: { data: ActivitiesResponse }) =>
      data.api.products.map(activityToAlgoliaRecord),
    settings: {
      customRanking: [...],
    },
  },
  {
    indexName: replicas.es.PRICE_ASC,
    query: ActivitiesQuery,
    transformer: ({ data }: { data: ActivitiesResponse }) =>
      data.api.products.map(activityToAlgoliaRecord),
    settings: {
      customRanking: [...],
    },
  }
];

Anyone has or had the same problem?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant