* @param wbRequest {@link WaybackRequest} either replay or capture-query
* @param isFuzzy unused (?)
* @return A {@link CDXQuery} object for the supplied request.
*/
protected CDXQuery createQuery(WaybackRequest wbRequest, boolean isFuzzy) {
CDXQuery query = new CDXQuery(wbRequest.getRequestUrl());
query.setLimit(limit);
//query.setSort(CDXQuery.SortType.reverse);
String statusFilter = baseStatusFilter;
if (wbRequest.isReplayRequest()) {
if (wbRequest.isBestLatestReplayRequest()) {
statusFilter = "statuscode:[23]..";
}
if (wbRequest.isTimestampSearchKey()) {
query.setClosest(wbRequest.getReplayTimestamp());
}
} else if (wbRequest.isCaptureQueryRequest()) {
// Add support for range calendar queries:
// eg: /2005-2007*/
// by mapping request start and end timestamp
// to cdx server from= and to= params
String start = wbRequest.getStartTimestamp();
if (start != null) {
query.setFrom(start);
}
String end = wbRequest.getEndTimestamp();
if (end != null) {
query.setTo(end);
}
}
if (timestampDedupLength > 0) {
//query.setCollapse(new String[]{"timestamp:" + timestampDedupLength});
query.setCollapseTime(timestampDedupLength);
}
// CDXServer#writeCdxResponse translates this into FieldRegexFilter
if (statusFilter != null && !statusFilter.isEmpty())
query.setFilter(new String[]{statusFilter});
return query;
}