I came across Algolia while reading Netlify’s blog.
I have a few Jekyll based sites and want to implement Algolia search on all those sites. I could get the basic search working but not able to fully accomplish my requirements. Here’s a brief of my requirements and the challenge I’m facing.
I have blog posts and each post has multiple tags (or labels). I want to use facets for tags such that when user clicks on a tag name, it only matches the “tags” attribute of the blog post, not the title or the content or any other attribute of the post. Let’s take an example.
Title: Blog Post 1
Content: Sample content for blog post 1 containing keywords tag1, tag2, tag3, tag4, tag5.
Tags: tag1, tag2, tag3
Title: Blog Post 2
Content: Sample content for blog post 2 containing keywords tag1, tag2, tag3, tag4, tag5.
Tags: tag2, tag3, tag4
Title: Blog Post 3
Content: Sample content for blog post 3 containing keywords tag1, tag2, tag3, tag4, tag5.
Tags: tag2, tag5
I want the facets and respective counts to appear like this:
However, since the content of all 3 blog posts contain all 5 tags (tag1, tag2, tag3, tag4, tag5), the facet count is much higher that what I need it to be. As mentioned earlier, I want the facet count to only count the matches of the “tags” attribute, and not the “Content” or other attributes. Is this possible?
Another related question -
Can the tag name be made a hyperlink inside blog post content such that clicking on that link brings the users to the Search page (that has Algolia search enabled) and directly how the results matching that tag. Is this possible? I’m not sure how to accomplish this.
Thanks in advance.