Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to filter by post type at search time #32

Merged
merged 4 commits into from
Sep 21, 2022

Conversation

kevinfodness
Copy link
Member

The restrict_post_types general setting actually filters which post types are eligible for being added to the index at index time, and there isn't a separate utility for filtering at search time. This PR clarifies (via comments) the intention of the restrict_post_types setting and adds a new filter for restricting post types at search time.

Copy link
Member

@dlh01 dlh01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks 🌳 to me as far as the code goes. To me, though, the "empty array for all" pattern seems like it requires some extra thinking. The plugin has access to the list of post types; could it pass those? As of now, the new elasticsearch_extensions_searchable_post_types filter is all-or-nothing in the sense that I couldn't use it to make a contextual decision, like "if X is present/absent, include/exclude Y." Either I supply my own complete list or I get the provider's defaults.

@kevinfodness
Copy link
Member Author

That's a great point. I'll add a parameter to that function that accepts a default, which can be passed through from adapter implementation classes with whatever the provider defaults are, which can then be further modified or completely overridden by userland code.

@kevinfodness kevinfodness merged commit 8d7239d into main Sep 21, 2022
@kevinfodness kevinfodness deleted the feature/filter-by-post-type branch September 21, 2022 15:45
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.

None yet

2 participants