Can't push post tags to index?

Hello community,

I’m trying to index post tags to use them in autocomplete. So I add tags like this:

\wp_set_post_tags($postId, $hashTags);

Then I re-index the stuff (All posts, custom post types and tags) from the backend. The added tags are not indexed when I view the index in Algolia Backend. What am I doing wrong?

Hey @aleksandr.epp ,

This method probably doesn’t trigger any hook we are listening to:

Maybe you could try re-saving the post after having added the tags?

Hey @rayrutjes,

The problem is, that I was not able to push my tags to index. I didn’t expect that tags are pushed after \wp_set_post_tags(); But I hoped to see them in the index at least after I pressed “Re-Index” button in backend. Or do you mean I should set tags -> save post -> re-index?

I get it now!

Tags are only indexed if they are at least associated with 1 post:

Does this explain the behaviour you have?

You can override that behaviour by doing:

add_filter('algolia_should_index_term', '__return_true');