gsa bugfix for date parser

pull/1/head
Michael Peter Christen 12 years ago
parent 3ce4c2f937
commit 0ad52ac4c3

@ -30,7 +30,6 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.solr.GSAResponseWriter;
import net.yacy.kelondro.logging.Log;
import net.yacy.search.Switchboard;
import net.yacy.search.index.YaCySchema;
import net.yacy.search.solr.EmbeddedSolrConnector;
import org.apache.solr.common.SolrException;
@ -65,23 +64,6 @@ public class searchresult {
return "text/xml";
}
public static class Sort {
public String sort, action, direction, mode, format;
public Sort(String d) {
this.sort = d;
String[] s = d.split(":");
this.action = s[0]; // date
this.direction = s[1]; // A or D
this.mode = s[2]; // S, R, L
this.format = s[3]; // d1
}
public String toSolr() {
if ("date".equals(this.action)) {
return YaCySchema.last_modified.name() + " " + (("D".equals(this.direction) ? "desc" : "asc"));
}
return null;
}
}
/**
* @param header
@ -118,7 +100,7 @@ public class searchresult {
post.put(CommonParams.ROWS, post.remove("num"));
post.put(CommonParams.ROWS, Math.min(post.getInt("num", 10), (authenticated) ? 5000 : 100));
post.remove("num");
Sort sort = new Sort(post.get(CommonParams.SORT, ""));
GSAResponseWriter.Sort sort = new GSAResponseWriter.Sort(post.get(CommonParams.SORT, ""));
String sorts = sort.toSolr();
if (sorts == null) {
post.remove(CommonParams.SORT);

@ -98,6 +98,25 @@ public class GSAResponseWriter implements QueryResponseWriter {
//public float maxScore;
}
public static class Sort {
public String sort = null, action = null, direction = null, mode = null, format = null;
public Sort(String d) {
this.sort = d;
String[] s = d.split(":");
if (s.length != 4) return;
this.action = s[0]; // date
this.direction = s[1]; // A or D
this.mode = s[2]; // S, R, L
this.format = s[3]; // d1
}
public String toSolr() {
if ("date".equals(this.action)) {
return YaCySchema.last_modified.name() + " " + (("D".equals(this.direction) ? "desc" : "asc"));
}
return null;
}
}
public GSAResponseWriter() {
super();
}
@ -166,7 +185,7 @@ public class GSAResponseWriter implements QueryResponseWriter {
SolrIndexSearcher searcher = request.getSearcher();
DocIterator iterator = response.iterator();
for (int i = 0; i < responseCount; i++) {
writer.write("<R N=\"" + (resHead.offset + i + 1) + "\"" + (i == 1 ? " L=\"\"" : "") + ">"); writer.write(lb);
writer.write("<R N=\"" + (resHead.offset + i + 1) + "\"" + (i == 1 ? " L=\"2\"" : "") + ">"); writer.write(lb);
int id = iterator.nextDoc();
Document doc = searcher.doc(id, SOLR_FIELDS);
List<Fieldable> fields = doc.getFields();

Loading…
Cancel
Save