DEV Community


Algolia attributes are flexible

katiekodes profile image Katie Originally published at on ・1 min read

Ohhhhh, I GET IT. There’s nowhere as you start an Algolia to define a schema for the data you plan to send it because it doesn’t care.

The only reason to use predictable, regular fields from one object to another is because after the fact, you use field names to determine what you care about with respect to searchability, and that could be a pain if you didn’t stick with a consistent word like “title.”

But Algolia doesn’t care if one “object” you pass it has a personName and another has a carMakeAndModel and yet another has a brand. It’s just more work for you to do to figure out that you probably could’ve uploaded all of these pieces of data as an item’s title if you’re just doing, say, search against different page types on a web site.

In other news, today I built a Netlify function that downloads all my data from a Sanity site as a list-of-objects, and another Netlify function that pushes a list-of-objects up into Algolia. (No, I haven’t hooked them up to each other – because I had this “aha moment” while trying to figure out how I wanted to go about doing so. My Sanity schema’s a hot mess, as in my example above, because I named things all sorts of crazy names for the purpose of making sure I didn’t rely on “magic coincidences” when hooking it up to stuff like 11ty.)

Discussion (0)

Editor guide