Skip to content

Commit

Permalink
added daterange option to gsa api
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Jun 18, 2013
1 parent e441a9d commit c36720d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions htroot/gsa/searchresult.java
Expand Up @@ -22,7 +22,9 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Date;

import net.yacy.cora.date.ISO8601Formatter;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.federate.solr.Ranking;
import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;
Expand Down Expand Up @@ -132,6 +134,20 @@ public static serverObjects respond(final RequestHeader header, final serverObje
if (bq.length() > 0) post.put("bq", bq);
if (bf.length() > 0) post.put("boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29
}
String daterange[] = post.remove("daterange");
if (daterange != null) {
String origfq = post.get(CommonParams.FQ);
String datefq = "";
for (String dr: daterange) {
String from_to[] = dr.split("\\.\\.");
if (from_to.length != 2) continue;
Date from = HeaderFramework.parseGSAFS(from_to[0]); if (from == null) continue;
Date to = HeaderFramework.parseGSAFS(from_to[1]); if (to == null) continue;
String z = CollectionSchema.last_modified.getSolrFieldName() + ":[" + ISO8601Formatter.FORMATTER.format(from) + " TO " + ISO8601Formatter.FORMATTER.format(to) + "]";
datefq = datefq.length() == 0 ? z : " OR " + z;
}
if (datefq.length() > 0) post.put(CommonParams.FQ, origfq == null || origfq.length() == 0 ? datefq : "(" + origfq + ") AND (" + datefq + ")");
}
post.put(CommonParams.FL,
CollectionSchema.content_type.getSolrFieldName() + ',' +
CollectionSchema.id.getSolrFieldName() + ',' +
Expand All @@ -157,8 +173,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
if (site != null && site[0].length() > 0) {
String origfq = post.get(CommonParams.FQ);
String sitefq = QueryModifier.parseCollectionExpression(site[0]);
post.put(CommonParams.FQ, origfq == null || origfq.length() == 0 ? sitefq :
"(" + origfq + ") AND (" + sitefq + ")");
post.put(CommonParams.FQ, origfq == null || origfq.length() == 0 ? sitefq : "(" + origfq + ") AND (" + sitefq + ")");
}

// get the embedded connector
Expand Down

0 comments on commit c36720d

Please sign in to comment.