// reverseFilters.addFilter(exclusion);
}
forwardFilters.addFilter(finalCounter);
// reverseFilters.addFilter(finalCounter);
forwardFilters.addFilter(new WindowEndFilter(resultsPerPage));
// int resultsPerDirection = (int) Math.floor(resultsPerPage / 2);
// reverseFilters.addFilter(new WindowEndFilter(resultsPerDirection));
startKey = keyUrl;
try {
// CloseableIterator<SearchResult> reverse =
// new AdaptedObjectFilterIterator<SearchResult>(
// source.getPrefixReverseIterator(startKey),
// reverseFilters);
// // reverse the reverseResults:
// ArrayList<SearchResult> reverseResults =
// new ArrayList<SearchResult>();
// while(reverse.hasNext()) {
// reverseResults.add(0, reverse.next());
// }
// now make a composite of the reverse and forwards:
CloseableIterator<SearchResult> forward =
source.getPrefixIterator(startKey);
//
// CompositeIterator<SearchResult> resultsItr =
// new CompositeIterator<SearchResult>();
// resultsItr.addComponent(reverseResults.iterator());
// resultsItr.addComponent(forward);
// and filter:
// filterRecords(resultsItr, forwardFilters, results, true);
filterRecords(forward, forwardFilters, results, true);
} catch (IOException e) {
throw new ResourceIndexNotAvailableException(
e.getLocalizedMessage());
}
} else if (searchType.equals(WaybackConstants.REQUEST_URL_QUERY)) {
results = new CaptureSearchResults();
// build up the FilterChain(s):
ObjectFilterChain<SearchResult> filters =
new ObjectFilterChain<SearchResult>();
filters.addFilter(guardrail);
filters.addFilter(new DuplicateRecordFilter());
filters.addFilter(new UrlMatchFilter(keyUrl));
if(hostMatchFilter != null) {
filters.addFilter(hostMatchFilter);
}
filters.addFilter(new EndDateFilter(endDate));
// possibly filter via exclusions:
if (exclusion != null) {
filters.addFilter(preExCounter);
filters.addFilter(exclusion);
}
filters.addFilter(finalCounter);
// OPTIMIZ: beginning the search at the startDate causes problems
// with deduplicated results. We need to be smarter about rolling
// backwards a ways if we start on a deduped record.
// startKey = keyUrl + " " + startDate;
startKey = keyUrl + " ";
// add the start and end windowing filters:
filters.addFilter(new WindowStartFilter(startResult));
filters.addFilter(new WindowEndFilter(resultsPerPage));
try {
filterRecords(source.getPrefixIterator(startKey), filters, results,
true);
} catch (IOException e) {
throw new ResourceIndexNotAvailableException(
e.getLocalizedMessage());
}
} else if (searchType.equals(WaybackConstants.REQUEST_URL_PREFIX_QUERY)) {
results = new UrlSearchResults();
// build up the FilterChain(s):
ObjectFilterChain<SearchResult> filters =
new ObjectFilterChain<SearchResult>();
filters.addFilter(guardrail);
filters.addFilter(new DuplicateRecordFilter());
filters.addFilter(new UrlPrefixMatchFilter(keyUrl));
if(hostMatchFilter != null) {
filters.addFilter(hostMatchFilter);
}
filters.addFilter(new DateRangeFilter(startDate, endDate));
// possibly filter via exclusions:
if (exclusion != null) {
filters.addFilter(preExCounter);
filters.addFilter(exclusion);
}
filters.addFilter(new CaptureToUrlResultFilter());
filters.addFilter(finalCounter);
startKey = keyUrl;
// add the start and end windowing filters:
filters.addFilter(new WindowStartFilter(startResult));
filters.addFilter(new WindowEndFilter(resultsPerPage));
try {
filterRecords(source.getPrefixIterator(startKey), filters, results,
true);
} catch (IOException e) {
throw new ResourceIndexNotAvailableException(