I want to search by issueIds with streaming to reduce memory consumption instead of using pagination.
The searchProvider has a method
searchProvider.search(Query var1, ApplicationUser var2, Collector var3)
I could write my own collector but there already exists a IssueIdsCollector, but I don’t know how to create a new instance of it and the documentation is lacking examples.
I could roll my own f.x.:
public class MyIssueIdCollector extends FieldableDocumentHitCollector {
private final Set<Long> issueIds = new HashSet<>(4096);
private final FieldSelector selector = fieldName -> {
if (fieldName.equals(DocumentConstants.ISSUE_ID)) {
return FieldSelectorResult.LOAD_AND_BREAK;
}
return FieldSelectorResult.NO_LOAD;
};
@Override
protected FieldSelector getFieldSelector() {
return selector;
}
@Override
public void collect(Document d) {
String issueIdString = d.get(DocumentConstants.ISSUE_ID);
issueIds.add(Long.valueOf(issueIdString));
}
public Set<Long> getIssueIds() {
return issueIds;
}
}
How can I use the IssueIdsCollector or should I not use it at all?
Do we have any examples of code achieving the same thing?