cms
cms copied to clipboard
Search indexes unpublished items (Algolia)
Bug description
I'm building out indexing for a client who currently has a lot of unpublished items in one collection. Due to the large discrepancy in number of entries vs the records that showed up in Algolia, I realized that when I submit my search index to Algolia it's indexing all the unpublished entries.
This will certainly create an issue when content that shouldn't yet be public starts showing up in the search index.
How to reproduce
- Set up Algolia indexing following the Statamic guide.
- Index collection with unpublished items.
- Unpublished items get sent to Algolia.
Logs
No response
Versions
Statamic 3.2.32 Pro Laravel 8.83.0 PHP 8.0.14 aryehraber/statamic-font-awesome 2.2.0 optimoapps/statamic-bard-text-align 1.0.2 statamic/seo-pro 2.3.2 statamic/ssg 0.9.0
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
Hey @fitzage,
I had the same issue. What I ended up doing is the following:
-
Add the "status" field to your index. You can do that in /config/statamic/search.php under indexes->default->fields. Add "status" to that array.
-
Add status to the "attributes for faceting" in the Algolia search ui:

- Configure your javascript algolia driver (in my case vue instant search) to only show "published" entries:
It's basically what @riasvdv suggested here: https://github.com/statamic/cms/discussions/5200
Hope this helps!
In 3.4, draft entries will not be indexed. Additionally, you can filter out entries however you want. #6318