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

FEATURE: Add Node-Type Filter #398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

erkenes
Copy link

@erkenes erkenes commented Sep 28, 2022

Create a method which allows to create a nodetype filter to include and exclude specific nodetypes

@erkenes
Copy link
Author

erkenes commented Sep 28, 2022

Simplified example:

public function getVehiclePages(NodeInterface $siteNode)
{
        $filter = [
                'Foo.Bar:Document.Vehicle',
                'Foo.Bar:Document.Motorcyle',
                '!Neos.Neos:Document' // this nodetype will be excluded
        ];

        $queryBuilder = new ElasticSearchQueryBuilder();
        $queryBuilder->query($siteNode);
        $queryBuilder->nodeTypeFilter(implode(',', $filter));
        
        // [...]
}

@erkenes erkenes force-pushed the feature/ee-nodetype-filter branch from e9b1557 to c750f23 Compare February 16, 2023 08:32
@erkenes
Copy link
Author

erkenes commented Feb 16, 2023

@Sebobo @daniellienert can you review this PR?

@erkenes erkenes force-pushed the feature/ee-nodetype-filter branch from c750f23 to b699e46 Compare February 16, 2023 10:17
@erkenes erkenes requested a review from kitsunet February 16, 2023 10:18
Copy link
Contributor

@daniellienert daniellienert left a comment

Choose a reason for hiding this comment

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

Hey @erkenes, thanks a lot for the improvement!
I have two comments tho.
Cheers Daniel

*/
public function nodeTypeFilter(array $expectedNodeTypes, array $excludedNodeTypes): QueryBuilderInterface
{
$excludeShould = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: It ends in an bool must / must_not query so should is a bit missleading here

Copy link
Author

Choose a reason for hiding this comment

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

I changed Should to Terms

* @throws QueryBuildingException
* @api
*/
public function nodeTypeFilter(array $expectedNodeTypes, array $excludedNodeTypes): QueryBuilderInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice if you would add a slim test in ElasticSearchQueryTest.

Copy link
Author

Choose a reason for hiding this comment

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

I added a test and adjusted the existing tests to match the new circumstances.

- Creates a method which allows to create a nodetype filter to
   include and exclude specific nodetypes
- Adds a test for the new filter function
- Adjusts existing tests to match the new circumstances
@erkenes erkenes force-pushed the feature/ee-nodetype-filter branch from b699e46 to 2b66844 Compare February 17, 2023 09:45
@erkenes erkenes requested review from daniellienert and removed request for kitsunet February 17, 2023 09:46
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.

3 participants