WP Plugin, how to remove post_content from index?

Just looking for a quick tip on how to customise what fields the WP plugin indexes. I only want to index the post ID and excerpt basically, I do not need or want the body of the post indexed.

How can I achieve this? I don7t think the docs are clear on this.

Hi @nathan.brown,

You can use the algolia_post_records and algolia_post_{$post_type}_records hooks. Indeed it seems like they are not documented. I will look to add this in the doc :+1:

Here is a simple example of how to remove the content attribute.

function vm_algolia_remove_attributes_from_post($records) {
    foreach ($records as &$record) {

    return $records;
add_filter('algolia_post_records', 'vm_algolia_remove_attribute');

Note that records is plural but it’s only one post. It’s because if the content is too long, the plugin will split one post into multiple records.

I forgot to say, the field indexed in Algolia have 2 goals. Some are used for the UX like the result page or the autocomplete dropdown and some are use to search. Keep in mind that if you remove the content and only keep the except, the engine will only search through the except. Hence, a lot of request might not return what you wished.

This depends on your site and content of course but I wanted to highlight this.

Thank you. This is important because we have things like the protection of personal information to consider in our app. We can have a post description in outside servers but the actual article must remain in our control.