- Sellers and their full game catalogs
- Games titles and a list of people who sell them
- Classified ads, ranked by business relevance (such as seller’s popularity)
Data source
When you’re fetching from a relational database like as MySQL, you usually have one entity per table and join tables for many-to-many mappings. After making aJOIN
request, serialized data might look like this:
JSON
Display sellers and their catalog
A nested data structure would work well to create a search experience where you would display a list of sellers and their associated games. From there, you could streamline the data by removing unnecessary attributes, and index it as follows:JSON
Searchable attributes
This experience focuses on sellers, which means you might want to search seller data in priority. For example, when a user searches for “mass effect”, you may want seller Mass Effect Fan to show up before sellers who sell Mass Effect 3, even if Mass Effect Fan doesn’t sell this game. To do so, you can create an order of priority in yoursearchableAttributes
, by setting name
first and games
second.
Displaying game titles and their sellers
You can use the same structure to create a search experience where you would display a list of games and their associated sellers. To achieve this, all you would need to do is to reverse the relationship: instead of nesting games per seller, you would nest sellers per game.JSON
Searchable attributes
This experience focuses on games, meaning you might want to search game data in priority. For example, when a user searches for “mass effect”, you may want game Mass Effect 3 to show up before seller Mass Effect Fan, especially if they don’t sell that game. For this, you can create an order of priority in yoursearchableAttributes
, by setting name
first and sellers.name
second.
Display classified ads ranked by business relevance
The first two experiences focus on exhaustiveness. No matter what users are looking for, they should get all possible options (all sellers per game or all games per seller). Another approach to building search is to be relevance-oriented: instead of showing all possibilities, you only show the best ones. For example, if users search for “grand theft auto”, they may not need to see all classified ads for Grand Theft Auto V. Instead, you could only show them the ones from the most popular sellers. In this case, you need to split your data and use a flat structure.JSON
customRanking
attribute.
This structure involves data duplication,
so you can use Algolia’s distinct feature to deduplicate records on game_title
.
Fpr more information, see:
Searchable attributes
This experience focuses on classified ads, so you may want to prioritize searching on game data. For example, when a user searches for “mass effect”, you may want ads for game Mass Effect 3 to show up before ads by user Mass Effect Fan. For this, you can create an order of priority in yoursearchableAttributes
, by setting game_title
first and seller_name
second.