I am trying to query data (using solr) and get Counts for a Day granularity.
I am having a problem with the below piece of code:
solrQuery.addDateRangeFacet("startTimeISO", date1.toDate(), date2.toDate(), "%2B1DAY");
solrQuery.setQuery(queryString);
QueryResponse response = null;
try {
response = solrClient.getSolrServer(getCollectionName(Constants.WebPeerAnomaliesModelTuple()._1())).query(solrQuery);
} catch (Exception exp) {
LOGGER.error("Failed to get facet results: ", exp);
}
The error I am getting here is:
"Can't add gap %2B1DAY to value Fri Nov 14 06:37:30 PST 2014 for field: startTimeISO"
Can somebody help me here what is the issue?
I am not sure why "%2B1DAY" would fail. I am getting the correct result when I do the same from the browser. If I query the below from url, it works: /select?facet=true&facet.date=startTimeISO&facet.date.start=NOW/DAY-30DAYS&facet.date.end=NOW/DAY%2B1DAY&facet.date.gap=%2B1DAY
Apologies if I am asking a trivial question. I am still trying to debug this. Any pointers will be helpful. Thanks.
UPDATE: SOLUTION:
I was able to debug this and find out why I am getting this error.
In my Java code, instead of "%2B1DAY", I should have added "+1Day". Querying through browser worked because + is %2B (url encoding) Sorry for the silly question. Hope it helps someone. :)