FAQ Basics How do I reduce the size of my records?

Last updated 28 April 2017

There are two main ways to decrease the size of records:

  1. Ask yourself if all of the data inside your record is necessary. If it’s not being used for searching, faceting, ranking, or display, then it’s safe to remove from your records on Algolia.
  2. Split the records into smaller slices and use Algolia’s distinct setting to only display the best result.

Generally you’ll want to split the records into smaller slices when you have one attribute that on your record that is especially large. This commonly happens with records built around textual content, like blog posts or PDFs.

In this case, the best thing to do is to split that attribute by paragraph and create records that are duplicates in every way except they have their own unique paragraph and their own unique objectID. For the objectID, you can take the objectID of the original record and append the paragraph number, so for example “12345” becomes “12345-0” and so on.

We must duplicate the data because Algolia does not have relationships between records and must be denormalized.

Let’s imagine we have a blog and a user is searching something that might match a blog post through its title. We don’t want multiple results to turn up when a user is searching.

Instead we only want the best result. Set attributeForDistinct to an attribute that all of the records from a single post have in common with each other and no others. A good example would be the slug of the blog post.

Then, when querying Algolia, set distinct to true. Then only the best matching result from each blog post will appear, leading to more diversity in the results.

Did you find this page helpful?

We're always looking for advice to help improve our documentation! Please let us know what's working (or what's not!) - we're constantly iterating thanks to the feedback we receive.

Send us your suggestions!