Simplifying Your Record Structure
Regarding records, you’ll want to think about the following:
- Keeping your record small
- How to handle complex record relationships and hierarchies between records
Keeping Record Size Small
Given the flexibility of the JSON format, it’s easy to create large records.
Large records cause many problems. For example, they’re nearly impossible to optimize or analyze in terms of relevance. They can slow down indexing and searching operations, and they will invariably go over record size limits.
There are typically two reasons for large records:
- too many attributes
- attributes with too much information
What to do with Large Records
Too many attributes
This happens when you aren’t selective about which attributes you include in your records. As a consequence, your records can contain too many attributes, most of which are useless for building search.
The solution is to remove unnecessary attributes.
Large attributes
When a record contains attributes with large amounts of content, like a “text” attribute” with the full content of a blog post, your record becomes ineffective for search. You can solve this by breaking up the full content into smaller chunks of text, and put each chunk in its own record. Not only does it significantly shrink the record size, but it also creates better relevance.
Handling data relationships
Simplifying your records doesn’t mean you have to lose hierarchy or relationships between records. For example, if you want your users to search products and to see them organized by vendor, then you need to store this product/vendor relationship in your index. This is possible because Algolia does not impose a data schema. You can organize your data in any way you want; keep it simple without losing complexity.