Search: Filter the search results based on block types#548
Search: Filter the search results based on block types#548
Conversation
This matches the regular API/meta-query behavior of this parameter
|
It's been awhile, but it looks like uploading the code to a sandbox is all that's needed to affect the output of the API response (albeit not in the desired way). I don't think it's possible to test locally, since the server needs to authenticate as w.org to get access to the custom ES index. Adding a PHPUnit test in the api.w.org repo is another way to test, and I'd recommend that too for all the normal reasons. I'd probably start by using Sense to test the raw ES query; I found that helpful before moving it to PHP code, since I ran into a lot of problems just getting the query right. There's info on accessing Sense in the A8C FG. I think you can get the raw query from |
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.