From b24572f30429a945b5161d6744f495f6f3743172 Mon Sep 17 00:00:00 2001 From: reger Date: Sun, 13 Jul 2014 00:11:17 +0200 Subject: [PATCH] fix GSA filter query assignment - use more parameter constants --- .../federate/solr/responsewriter/GSAResponseWriter.java | 7 ++++--- source/net/yacy/http/servlets/GSAsearchServlet.java | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java index 61998d63d..bcba91477 100644 --- a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java +++ b/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java @@ -40,6 +40,7 @@ import net.yacy.search.schema.CollectionSchema; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexableField; +import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.XML; @@ -154,7 +155,7 @@ public class GSAResponseWriter implements QueryResponseWriter { // parse response header ResHead resHead = new ResHead(); NamedList val0 = (NamedList) responseHeader.get("params"); - resHead.rows = Integer.parseInt((String) val0.get("rows")); + resHead.rows = Integer.parseInt((String) val0.get(CommonParams.ROWS)); resHead.offset = response.offset(); // equal to 'start' resHead.numFound = response.matches(); //resHead.df = (String) val0.get("df"); @@ -200,14 +201,14 @@ public class GSAResponseWriter implements QueryResponseWriter { writer.write(""); if (prevStart >= 0) { writer.write(""); - XML.escapeCharData("/gsa/search?q=" + request.getParams().get("q") + "&site=" + site + + XML.escapeCharData("/gsa/search?q=" + request.getParams().get(CommonParams.Q) + "&site=" + site + "&lr=&ie=UTF-8&oe=UTF-8&output=xml_no_dtd&client=" + client + "&access=" + access + "&sort=" + sort + "&start=" + prevStart + "&sa=N", writer); // a relative URL pointing to the NEXT results page. writer.write(""); } if (nextNum > 0) { writer.write(""); - XML.escapeCharData("/gsa/search?q=" + request.getParams().get("q") + "&site=" + site + + XML.escapeCharData("/gsa/search?q=" + request.getParams().get(CommonParams.Q) + "&site=" + site + "&lr=&ie=UTF-8&oe=UTF-8&output=xml_no_dtd&client=" + client + "&access=" + access + "&sort=" + sort + "&start=" + nextStart + "&num=" + nextNum + "&sa=N", writer); // a relative URL pointing to the NEXT results page. writer.write(""); diff --git a/source/net/yacy/http/servlets/GSAsearchServlet.java b/source/net/yacy/http/servlets/GSAsearchServlet.java index 0109a308b..00311c61b 100644 --- a/source/net/yacy/http/servlets/GSAsearchServlet.java +++ b/source/net/yacy/http/servlets/GSAsearchServlet.java @@ -50,6 +50,7 @@ import net.yacy.server.serverObjects; import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrException; import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.DisMaxParams; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrRequestInfo; import org.apache.solr.response.QueryResponseWriter; @@ -107,7 +108,7 @@ public class GSAsearchServlet extends HttpServlet { // create post serverObjects post = new serverObjects(); - post.put("q", ""); post.put("num", "0"); + post.put(CommonParams.Q, ""); post.put("num", "0"); // convert servletrequest parameter to old style serverObjects map Map map = header.getParameterMap(); Iterator> it = map.entrySet().iterator(); @@ -136,7 +137,7 @@ public class GSAsearchServlet extends HttpServlet { post.put(CommonParams.ROWS, Math.min(post.getInt(CommonParams.ROWS, 10), (authenticated) ? 100000000 : 100)); // set ranking - if (post.containsKey("sort")) { + if (post.containsKey(CommonParams.SORT)) { // if a gsa-style sort attribute is given, use this to set the solr sort attribute GSAResponseWriter.Sort sort = new GSAResponseWriter.Sort(post.get(CommonParams.SORT, "")); String sorts = sort.toSolr(); @@ -151,8 +152,8 @@ public class GSAsearchServlet extends HttpServlet { String fq = ranking.getFilterQuery(); String bq = ranking.getBoostQuery(); String bf = ranking.getBoostFunction(); - if (fq.length() > 0) post.put(CommonParams.FQ, bq); - if (bq.length() > 0) post.put("bq", bq); + if (fq.length() > 0) post.put(CommonParams.FQ, fq); + if (bq.length() > 0) post.put(DisMaxParams.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");