Skip to content

Apply enabled/stock default filters on the incremental indexing path#157

Open
loevgaard wants to merge 1 commit into
issue-111-remove-entity-documentfrom
issue-112-incremental-default-filters
Open

Apply enabled/stock default filters on the incremental indexing path#157
loevgaard wants to merge 1 commit into
issue-111-remove-entity-documentfrom
issue-112-incremental-default-filters

Conversation

@loevgaard

Copy link
Copy Markdown
Member

What

Full reindexing and incremental (Doctrine event) indexing used two different, inconsistent filter sets. The enabled / stock_available default filters only existed as query-builder subscribers (which run during full reindex), while the incremental path only ran the object filters tagged setono_sylius_meilisearch.entity_filter — of which only channels_aware had an object-filter counterpart. Consequences:

  • editing a disabled product re-added it to the index;
  • disabling a product didn't remove it (nothing on the incremental path ever deleted).

Two parts:

  1. Unify the filters. Ship EnabledEntityFilter and StockAvailableEntityFilter (the object-filter counterparts of the enabled / stock_available query-builder subscribers), registered under the same per-index default_filters toggles as the subscribers — so the incremental path applies the same rules as the full reindex.
  2. Delete on filter failure. In DefaultIndexer::indexEntities(), when an entity fails the object filter, its document is removed from that scope's index (batched per scope) instead of being silently skipped. So "disable a product" (or de-stock it) actively removes it from search on the very next save.

Full reindex already routes through indexEntities, but its entities are pre-filtered by the query-builder subscribers, so the object filters are consistent and no spurious deletes occur (verified: the functional SearchTest still passes).

Testing

  • EnabledEntityFilterTest / StockAvailableEntityFilterTest: full logic incl. other-index scopes, non-toggleable/non-product entities, untracked vs out-of-stock variants, no-variant products.
  • DefaultIndexerTest::it_removes_a_filtered_out_entity_from_the_index: a filtered-out entity triggers deleteDocuments([id]).

Closes #112


Stacked on #156 (#111).

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.05128% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.72%. Comparing base (00d3831) to head (be49d96).

Files with missing lines Patch % Lines
...encyInjection/SetonoSyliusMeilisearchExtension.php 50.00% 4 Missing ⚠️
src/Filter/Entity/StockAvailableEntityFilter.php 78.57% 3 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##             issue-111-remove-entity-document     #157      +/-   ##
======================================================================
+ Coverage                               45.17%   45.72%   +0.54%     
- Complexity                                734      748      +14     
======================================================================
  Files                                     131      133       +2     
  Lines                                    2406     2443      +37     
======================================================================
+ Hits                                     1087     1117      +30     
- Misses                                   1319     1326       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loevgaard loevgaard force-pushed the issue-112-incremental-default-filters branch 2 times, most recently from df8d23f to 6952c4f Compare July 10, 2026 17:20
@loevgaard loevgaard force-pushed the issue-111-remove-entity-document branch from 26b03ca to 5df71ee Compare July 10, 2026 17:20
Full and incremental indexing used inconsistent filter sets: the enabled
and stock_available default filters only existed as query-builder
subscribers (full reindex), while the incremental (Doctrine event) path
only ran the tagged object filters, of which only channels_aware had an
object-filter counterpart. So editing a disabled product re-added it, and
disabling a product never removed it.

- Ship EnabledEntityFilter and StockAvailableEntityFilter (object-filter
  counterparts of the query-builder subscribers), registered under the same
  per-index default_filters toggles as the subscribers.
- In DefaultIndexer::indexEntities(), when an entity fails the object filter,
  remove its document from that scope's index (batched per scope) instead of
  silently skipping it. Disabling or de-stocking a product now removes it
  from search on its next save.

Closes #112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant