Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- setting the same default ranking in the solr interface as for YaCy search interfaces if no other ranking attributes are given - using the YaCy ranking in the GSA interface only if there was not given a GSA-style sort attribute - to avoid confusion about correct ranking attributes, only the default '0'-ranking profile is used and not scenario-adopted (site, date) because that should be configurable in the web interface before it is used actually for ranking.
Michael Peter Christen082e3274d66b
diff --git a/htroot/gsa/searchresult.java b/htroot/gsa/searchresult.javaindex 2073a3247..d10817237 100644--- a/htroot/gsa/searchresult.java+++ b/htroot/gsa/searchresult.java@@ -23,7 +23,6 @@ import java.io.OutputStream;import java.io.OutputStreamWriter;import java.io.Writer;import java.util.ArrayList;-import java.util.Map;import net.yacy.cora.document.UTF8;import net.yacy.cora.federate.solr.Ranking;@@ -116,11 +115,24 @@ public class searchresult {post.put(CommonParams.ROWS, post.remove("num"));post.put(CommonParams.ROWS, Math.min(post.getInt(CommonParams.ROWS, 10), (authenticated) ? 5000 : 100));- Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(0);- String bq = ranking.getBoostQuery();- String bf = ranking.getBoostFunction();- if (bq.length() > 0) post.put("bq", bq); // a boost query that moves double content to the back- if (bf.length() > 0) post.put(ranking.getMethod() == Ranking.BoostFunctionMode.add ? "bf" : "boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29+ // set ranking+ if (post.containsKey("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();+ if (sorts == null) {+ post.remove(CommonParams.SORT);+ } else {+ post.put(CommonParams.SORT, sorts);+ }+ } else {+ // if no such sort attribute is given, use the ranking as configured for YaCy+ Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(0);+ String bq = ranking.getBoostQuery();+ String bf = ranking.getBoostFunction();+ if (bq.length() > 0) post.put("bq", bq); // a boost query that moves double content to the back+ if (bf.length() > 0) post.put(ranking.getMethod() == Ranking.BoostFunctionMode.add ? "bf" : "boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29+ }post.put(CommonParams.FL,CollectionSchema.content_type.getSolrFieldName() + ',' +CollectionSchema.id.getSolrFieldName() + ',' +@@ -137,16 +149,10 @@ public class searchresult {post.put("hl.simple.pre", "<b>");post.put("hl.simple.post", "</b>");post.put("hl.fragsize", Integer.toString(SearchEvent.SNIPPET_MAX_LENGTH));- GSAResponseWriter.Sort sort = new GSAResponseWriter.Sort(post.get(CommonParams.SORT, ""));- String sorts = sort.toSolr();- if (sorts == null) {- post.remove(CommonParams.SORT);- } else {- post.put(CommonParams.SORT, sorts);- }+String[] site = post.remove("site"); // example: col1|col2- String[] access = post.remove("access");- String[] entqr = post.remove("entqr");+ //String[] access = post.remove("access");+ //String[] entqr = post.remove("entqr");// add sites operatorif (site != null && site[0].length() > 0) {@@ -184,6 +190,7 @@ public class searchresult {}// set some context for the writer+ /*Map<Object,Object> context = req.getContext();context.put("ip", header.get("CLIENTIP", ""));context.put("client", "vsm_frontent");@@ -191,7 +198,8 @@ public class searchresult {context.put("site", site == null ? "" : site);context.put("access", access == null ? "p" : access[0]);context.put("entqr", entqr == null ? "3" : entqr[0]);-+ */+// write the result directly to the output streamWriter ow = new FastWriter(new OutputStreamWriter(out, UTF8.charset));try {diff --git a/htroot/solr/select.java b/htroot/solr/select.javaindex 1b1d2ba8c..1c85531e9 100644--- a/htroot/solr/select.java+++ b/htroot/solr/select.java@@ -28,6 +28,7 @@ import java.util.Map;import javax.servlet.ServletException;import net.yacy.cora.document.UTF8;+import net.yacy.cora.federate.solr.Ranking;import net.yacy.cora.federate.solr.SolrServlet;import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;import net.yacy.cora.federate.solr.responsewriter.EnhancedXMLResponseWriter;@@ -160,7 +161,17 @@ public class select {if (!post.containsKey(CommonParams.START)) post.put(CommonParams.START, post.remove("startRecord", 0)); // sru patchif (!post.containsKey(CommonParams.ROWS)) post.put(CommonParams.ROWS, post.remove("maximumRecords", 10)); // sru patchpost.put(CommonParams.ROWS, Math.min(post.getInt(CommonParams.ROWS, 10), (authenticated) ? 10000 : 100));-++ // set default ranking if this is not given in the request+ if (!post.containsKey("sort")) {+ if (!post.containsKey("defType")) post.put("defType", "edismax");+ Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(0);+ String bq = ranking.getBoostQuery();+ String bf = ranking.getBoostFunction();+ if (!post.containsKey("bq") && bq.length() > 0) post.put("bq", bq); // a boost query that moves double content to the back+ if (!(post.containsKey("bf") || post.containsKey("boost")) && bf.length() > 0) post.put(ranking.getMethod() == Ranking.BoostFunctionMode.add ? "bf" : "boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29+ }+// get a response writer for the resultString wt = post.get(CommonParams.WT, "xml"); // maybe use /solr/select?q=*:*&start=0&rows=10&wt=exmlQueryResponseWriter responseWriter = RESPONSE_WRITER.get(wt);diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.javaindex 746e30c4a..ecd3e66e4 100644--- a/source/net/yacy/search/query/QueryParams.java+++ b/source/net/yacy/search/query/QueryParams.java@@ -386,7 +386,8 @@ public final class QueryParams {final SolrQuery params = new SolrQuery();params.setQuery(this.queryGoal.collectionQueryString(this.indexSegment.fulltext().getDefaultConfiguration()).toString());params.setParam("defType", "edismax");- Ranking ranking = indexSegment.fulltext().getDefaultConfiguration().getRanking(this.ranking.coeff_date == RankingProfile.COEFF_MAX ? 1 : (this.modifier.sitehash != null || this.modifier.sitehost != null) ? 2 : 0); // for a by-date ranking select different ranking profile+ Ranking ranking = indexSegment.fulltext().getDefaultConfiguration().getRanking(0);+ //Ranking ranking = indexSegment.fulltext().getDefaultConfiguration().getRanking(this.ranking.coeff_date == RankingProfile.COEFF_MAX ? 1 : (this.modifier.sitehash != null || this.modifier.sitehost != null) ? 2 : 0); // for a by-date ranking select different ranking profileString bq = ranking.getBoostQuery();String bf = ranking.getBoostFunction();if (bq.length() > 0) params.setParam("bq", bq); // a boost query that moves double content to the backdiff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.javaindex 1ae94deb4..f6ec0b5ba 100644--- a/source/net/yacy/search/query/SearchEvent.java+++ b/source/net/yacy/search/query/SearchEvent.java@@ -771,7 +771,7 @@ public final class SearchEvent {// apply all constraintstry {pollloop: for (URIMetadataNode iEntry: nodeList) {-+if ( !this.query.urlMask_isCatchall ) {// check url maskif (!iEntry.matches(this.query.urlMask)) {@@ -1104,7 +1104,7 @@ public final class SearchEvent {Element<URIMetadataNode> localEntryElement = this.nodeStack.sizeQueue() > 0 ? this.nodeStack.poll() : null;URIMetadataNode node = localEntryElement == null ? null : localEntryElement.getElement();if (node != null) {- String solrsnippet = this.snippets.remove(ASCII.String(node.hash())); // we ca remove this because it's used only once+ String solrsnippet = this.snippets.remove(ASCII.String(node.hash())); // we can remove this because it's used only onceif (solrsnippet != null && solrsnippet.length() > 0) {final TextSnippet snippet = new TextSnippet(node.hash(), solrsnippet, true, ResultClass.SOURCE_CACHE, "");ResultEntry re = new ResultEntry(node, this.query.getSegment(), this.peers, snippet, null, 0);