Search: Filter the search results based on block types #548
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the
allowed_blocksmeta filter is set, we should also pass that through to the ElasticSearch filters. Currently, if you make a request via the API with theallowed_blocksparameter, it will correctly return only patterns with those blocks. If you add a search term, it skips the filtering and returns all matching patterns. Searches should also return only patterns with matching blocks.I've already added the
wpop_contains_block_typesmeta to the synced data in 8ac046d. This PR adds the filter to the ES query so that it should do the same regex matching to return only patterns with a subset of blocks in the givenallowed_blocks.See #540 (comment). Fixes #547.
How to test the changes in this Pull Request:
No idea 😓 this is my best guess based on the ES docs. @iandunn you've worked on the search code here before, how can I test this either locally or on a sandbox?
Note - search queries without
allowed_blocksshould still work, as the pattern directory itself doesn't supplyallowed_blocks.