Hello, I’m looking for advice on how to index our records. The tldr is should we structure our records flat or nested?
Context: we have a WordPress website of news articles, we want users to be able to search for posts (articles), pages, authors and tags and categories. So a search result could be a author or a post or a category.
- Should we structure our records flat but with different ‘record types’, one for author, one for post, etc.?
- Should all records have the same properties? For eg, if a post record has a
excerpt
property should a tag and author record also haveexcerpt
even though its not relevant to those types of records?
Eg of flat record structure in an index.
// Post
{
"type": "post",
"title": "",
"excerpt": "",
"url": "",
"image": "",
"content": "",
"date": ""
}
// Page
{
"type": "page",
"title": "",
"excerpt": "",
"url": "",
"image": "",
"content": "",
"date": ""
}
// Author
{
"type": "author",
"name": "",
"url": "",
"image": ""
}
// Term
{
"type": "category|tag",
"name": "",
"url": "",
"image": ""
}
Eg of nested
// Post or page
{
"type": "post|page",
"title": "",
"excerpt": "",
"url": "",
"image": "",
"content": "",
"date": "",
"author": {
"name": "",
"url": "",
"image": ""
}
"tags": [
{
"type": "category|tag",
"name": "",
"url": "",
"image": ""
},
...
]
}