Skip to content

Apache Lucene open-source search software

GITHUB-13218: Add migrate entry for Collector to CollectorManager migration (#13238)

Zach Chen5b5a02d0cd91
diff --git a/lucene/MIGRATE.md b/lucene/MIGRATE.md
index dcd55d0503e..38c14b8715f 100644
--- a/lucene/MIGRATE.md
+++ b/lucene/MIGRATE.md
@@ -197,6 +197,34 @@ enum.
`TimeLimitingCollector` has been removed, use `IndexSearcher#setTimeout(QueryTimeout)` to time out queries instead.
+### IndexSearch#search(Query, Collector) being deprecated in favor of IndexSearcher#search(Query, CollectorManager) (LUCENE-10002)
+
+`IndexSearch#search(Query, Collector)` is now being deprecated in favor of `IndexSearcher#search(Query, CollectorManager)`,
+as `CollectorManager` implementation would allow taking advantage of intra-query concurrency via its map-reduce API design.
+To migrate, use a provided `CollectorManager` implementation that suits your use cases, or change your `Collector` implementation
+to follow the new API pattern. The straight forward approach would be to instantiate the single-threaded `Collector` in a wrapper `CollectorManager`.
+
+For example
+```java
+public class CustomCollectorManager implements CollectorManager<CustomCollector, List<Object>> {
+ @Override
+ public CustomCollector newCollector() throws IOException {
+ return new CustomCollector();
+ }
+
+ @Override
+ public List<Object> reduce(Collection<CustomCollector> collectors) throws IOException {
+ List<Object> all = new ArrayList<>();
+ for (CustomCollector c : collectors) {
+ all.addAll(c.getResult());
+ }
+
+ return all;
+ }
+}
+
+List<Object> results = searcher.search(query, new CustomCollectorManager());
+```
## Migration from Lucene 9.0 to Lucene 9.1
### Test framework package migration and module (LUCENE-10301)