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

Should the static search methods in FacetsCollector take a FacetsCollector as last argument? #13725

Closed
javanna opened this issue Sep 5, 2024 · 2 comments · Fixed by #13733
Closed
Labels
discussion Discussion

Comments

@javanna
Copy link
Contributor

javanna commented Sep 5, 2024

I have bumped into this and wondered for a while, why do the following methods take a generic Collector as last argument?

public static TopDocs search(IndexSearcher searcher, Query q, int n, Collector fc)

public static TopFieldDocs search(IndexSearcher searcher, Query q, int n, Sort sort, Collector fc)

public static TopFieldDocs search(IndexSearcher searcher, Query q, int n, Sort sort, boolean doDocScores, Collector fc)

public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, Collector fc)

public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, Sort sort, Collector fc)

public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, Sort sort, boolean doDocScores, Collector fc)

Are these methods ever called providing a collector that's not an instance of FacetsCollector? If so, should these methods to be moved to a more appropriate location, outside of FacetsCollector? If not, should that argument become FacetsCollector?

This is somewhat related to #12892 in that if we want to remove search(Query, Collector) we need to get rid of the usages in these static methods. We can either change the signature of these methods to take a generic CollectorManager, or a FacetsCollectorManager if we decide that it's more appropriate to restrict the type of accepted collectors.

@javanna javanna added the discussion Discussion label Sep 5, 2024
@gsmiller
Copy link
Contributor

gsmiller commented Sep 5, 2024

My vote would be to be more restrictive with these signatures and specify FacetsCollectorManager given that these are sugar methods meant to make it easier to do faceting while also the "main" search. Today's faceting module all works against FacetsCollector explicitly in the various APIs, so having a generic Collector or CollectorManager here seems confusing IMO.

@javanna
Copy link
Contributor Author

javanna commented Sep 6, 2024

I agree @gsmiller , I am inclined to be stricter. Also, while we make this breaking change, we can go directly from Collector to FacetsCollectorManager. I am also considering moving these static methods to FacetsCollectorManager. It feels weird to have them exposed to FacetsCollector but require the corresponding manager.

javanna added a commit to javanna/lucene that referenced this issue Sep 6, 2024
We have a few public static utility search methods in FacetsCollector that accept
a Collector as last argument. In practice, these are expected to be called
providing a `FacetsCollector` as last argument. Also, we'd like to remove all
the search methods that take a `Collector` in favour of those that take a
`CollectorManager` (see apache#12892).

This commit adds the corresponding functionality to `FacetsCollectorManager`.
The new methods take a `FacetsCollectorManager` as last argument. The return type
has to be adapted to include also the facets results that were before made
available through the collector argument.

In order for tests to all work I had to add support for `keepScores` to
`FacetsCollectorManager` which was missing.

Closes apache#13725
@javanna javanna closed this as completed in 47c0a6e Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants