Post comments indexing

Quick question - is it possible to index post comments into Algolia? I can’t seem to find a simply way to enable it from the plugin settings. Thanks!

1 Like

Hi @chiplay,

Unfortunately there is no way to index comments as of today.
I’d love to hear more about your use case.

Best,

Hey @rayrutjes - thanks for getting back to me. I’m working on a blog concept that uses React/Express app and pulls all content from Algolia - not only for search, but also for page/post content (using WP as a general CMS and Algolia as the caches storage engine). That means theoretically, no visitors will be hitting the WP/PHP templates at all, just loading js and Algolia content.

The only gap currently is in displaying the comment threads for each post. I have used the JSON API to POST new comments in the past, and could also use it to fetch comments per post as well, but I’d much rather have an index of wp_posts_comments that I can facetFilter by post_id and pull in that way.

One idea I had was to use the algolia_searchable_post_shared_attributes (already using it for adding ACF fields) to pull in the comments and append it to the post data, but I’m trying hard to keep each post to a single Algolia record and since the content of each post is already pushing the record limits in some cases, adding full comment threads to each record probably isn’t going to cut it.

If you have any ideas on how else I might approach storing comments in Algolia, I’d love to know - thanks for you help and the great plug-in / service!

@chiplay super interesting use case you have there.
Funny part being that we are currently working on a similar approach :wink:

Regarding the comments however, there is some complexity linked to the fact that comments can be indefinitely nested, which requires he frontend somehow to re-construct the tree.

We can not store multiple comments in a same thread because it would reach the record size limit.

An easy alternative would be to use a third party service like Disqus.
If you want to try and index comments and submit a PR, I’d be happy to provide you guidance and help you out. I’m just not sure yet if it’s a good idea to add this to the plugin, given that searching in comments is not really common, and Algolia is not really designed to be used as a database.

Let me know what you end up doing,