The commented line tries to filter a collection of a single node. That does not make much sense. In general filter works like this but you have to pass a list of nodes that shall be filtered.
We’d need a little additional context here to answer this. In your search plugin, there must be a place where you receive an array of all nodes that are searched, no? This would be the place where you can do new FlowQuery($yourNodeArray)->…
Having said that, however, I doubt that doing a live filtering of those nodes will yield the search performance you want. Any reason why you’re not relying on an existing search plugin like Flowpack.SimpleSearch?
This will first find all Documents below the $startingNode and then apply the filter. The two opertions find() and filter() return a new modified flowQueryContext while get() will return the content of the context for use outside of flowQuery.
As @beheist commented that is probably not the ideal way to search across many nodes. It does not provide a fulltext index and the performance will drop if you query too much nodes. So use such a solution only if you have a good reason to assume that the number of nodes you are filtering will not increase too much over time.
You still add only one node to the context. You have to specify the nodes you want to filter first. The code you commented out tries to filter a list that contains a single node.
When working with flowQuery you can start with a single expression and add traversing and filtering step by step.