Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Merge branch 'master' into HEAD

Michael Peter Christen7603e879dc60
diff --cc .classpath
index d3665f212,2570de621..7cf627838
--- a/.classpath
+++ b/.classpath
@@@ -1,91 -1,82 +1,90 @@@
- <?xml version="1.0" encoding="UTF-8"?>
- <classpath>
- <classpathentry kind="src" path="source"/>
- <classpathentry excluding="api/|env/|processing/domaingraph/applet/|yacy/|api/bookmarks/|api/ymarks/|api/bookmarks/posts/|api/bookmarks/tags/|api/bookmarks/xbel/|solr/|gsa/|solr/collection1/" kind="src" path="htroot"/>
- <classpathentry excluding="bookmarks/|ymarks/|bookmarks/posts/|bookmarks/tags/|bookmarks/xbel/" kind="src" path="htroot/api"/>
- <classpathentry kind="src" path="htroot/env"/>
- <classpathentry kind="src" path="htroot/yacy"/>
- <classpathentry excluding="posts/|tags/|xbel/" kind="src" path="htroot/api/bookmarks"/>
- <classpathentry kind="src" path="htroot/api/ymarks"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
- <classpathentry excluding="collection1/" kind="src" path="htroot/solr"/>
- <classpathentry kind="src" path="htroot/gsa"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/jetty-continuation-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/jetty-http-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/jetty-io-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/jetty-security-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/jetty-server-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/jetty-servlet-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/jetty-servlets-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/jetty-util-8.1.13.v20130916.jar"/>
- <classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
- <classpathentry kind="lib" path="lib/J7Zip-modified.jar"/>
- <classpathentry kind="lib" path="lib/webcat-0.1-swf.jar"/>
- <classpathentry kind="lib" path="lib/activation.jar"/>
- <classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/>
- <classpathentry kind="lib" path="lib/poi-3.6-20091214.jar"/>
- <classpathentry kind="lib" path="lib/poi-scratchpad-3.6-20091214.jar"/>
- <classpathentry kind="lib" path="lib/bcmail-jdk15-145.jar"/>
- <classpathentry kind="lib" path="lib/bcprov-jdk15-145.jar"/>
- <classpathentry kind="lib" path="lib/jsch-0.1.42.jar"/>
- <classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
- <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.12-bin.jar"/>
- <classpathentry kind="lib" path="lib/apache-mime4j-0.6.jar"/>
- <classpathentry kind="lib" path="lib/commons-fileupload-1.2.2.jar"/>
- <classpathentry kind="lib" path="lib/json-simple-1.1.jar"/>
- <classpathentry kind="lib" path="lib/xercesImpl.jar"/>
- <classpathentry kind="lib" path="lib/xml-apis.jar"/>
- <classpathentry kind="lib" path="lib/geronimo-stax-api_1.0_spec-1.0.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-compress-1.4.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
- <classpathentry kind="lib" path="lib/javax.servlet-3.0.0.v201112011016.jar"/>
- <classpathentry kind="lib" path="lib/jaudiotagger-2.0.4-20111207.115108-15.jar"/>
- <classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
- <classpathentry kind="lib" path="lib/spatial4j-0.3.jar"/>
- <classpathentry kind="lib" path="lib/jcl-over-slf4j-1.7.2.jar"/>
- <classpathentry kind="lib" path="lib/slf4j-api-1.7.2.jar"/>
- <classpathentry kind="lib" path="lib/zookeeper-3.4.5.jar"/>
- <classpathentry kind="lib" path="lib/guava-13.0.1.jar"/>
- <classpathentry kind="lib" path="lib/wstx-asl-3.2.9.jar"/>
- <classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.2.jar"/>
- <classpathentry kind="lib" path="lib/log4j-over-slf4j-1.7.2.jar"/>
- <classpathentry kind="lib" path="lib/httpclient-4.3.1.jar"/>
- <classpathentry kind="lib" path="lib/httpcore-4.3.jar"/>
- <classpathentry kind="lib" path="lib/httpmime-4.3.1.jar"/>
- <classpathentry kind="lib" path="lib/noggit-0.5.jar"/>
- <classpathentry kind="lib" path="lib/metadata-extractor-2.6.2.jar"/>
- <classpathentry kind="lib" path="lib/jcifs-1.3.17.jar"/>
- <classpathentry kind="lib" path="lib/fontbox-1.8.2.jar"/>
- <classpathentry kind="lib" path="lib/jempbox-1.8.2.jar"/>
- <classpathentry kind="lib" path="lib/pdfbox-1.8.2.jar"/>
- <classpathentry kind="lib" path="lib/lucene-analyzers-common-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-analyzers-phonetic-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-classification-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-codecs-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-core-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-facet-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-grouping-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-highlighter-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-join-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-memory-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-misc-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-queries-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-queryparser-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-spatial-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-suggest-4.5.0.jar"/>
- <classpathentry kind="lib" path="lib/solr-core-4.5.0.jar" sourcepath="/Volumes/Tres/noBackup/Downloads/solr-4.5.0/solr/core/src/java"/>
- <classpathentry kind="lib" path="lib/solr-solrj-4.5.0.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="lib" path="lib/icu4j-core.jar"/>
- <classpathentry kind="lib" path="lib/htmllexer.jar"/>
- <classpathentry kind="lib" path="lib/jena-2.6.4.jar"/>
- <classpathentry kind="lib" path="lib/sax-2.0.1.jar"/>
- <classpathentry kind="lib" path="lib/arq-2.8.7.jar"/>
- <classpathentry kind="lib" path="lib/iri-0.8.jar"/>
- <classpathentry kind="lib" path="lib/jsoup-1.6.3.jar"/>
- <classpathentry kind="output" path="gen"/>
- </classpath>
+ <?xml version="1.0" encoding="UTF-8"?>
+ <classpath>
+ <classpathentry kind="src" path="source"/>
+ <classpathentry excluding="api/|env/|processing/domaingraph/applet/|yacy/|api/bookmarks/|api/ymarks/|api/bookmarks/posts/|api/bookmarks/tags/|api/bookmarks/xbel/|solr/|gsa/|solr/collection1/" kind="src" path="htroot"/>
+ <classpathentry excluding="bookmarks/|ymarks/|bookmarks/posts/|bookmarks/tags/|bookmarks/xbel/" kind="src" path="htroot/api"/>
+ <classpathentry kind="src" path="htroot/env"/>
+ <classpathentry kind="src" path="htroot/yacy"/>
+ <classpathentry excluding="posts/|tags/|xbel/" kind="src" path="htroot/api/bookmarks"/>
+ <classpathentry kind="src" path="htroot/api/ymarks"/>
+ <classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
+ <classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
+ <classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
+ <classpathentry excluding="collection1/" kind="src" path="htroot/solr"/>
+ <classpathentry kind="src" path="htroot/gsa"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
++ <classpathentry kind="lib" path="lib/jetty-continuation-8.1.13.v20130916.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-http-8.1.13.v20130916.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-io-8.1.13.v20130916.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-security-8.1.13.v20130916.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-server-8.1.13.v20130916.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-servlet-8.1.13.v20130916.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-servlets-8.1.13.v20130916.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-util-8.1.13.v20130916.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/J7Zip-modified.jar"/>
+ <classpathentry kind="lib" path="lib/webcat-0.1-swf.jar"/>
+ <classpathentry kind="lib" path="lib/activation.jar"/>
+ <classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/>
+ <classpathentry kind="lib" path="lib/poi-3.6-20091214.jar"/>
+ <classpathentry kind="lib" path="lib/poi-scratchpad-3.6-20091214.jar"/>
+ <classpathentry kind="lib" path="lib/bcmail-jdk15-145.jar"/>
+ <classpathentry kind="lib" path="lib/bcprov-jdk15-145.jar"/>
++ <classpathentry kind="lib" path="lib/jsch-0.1.50.jar"/>
+ <classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
+ <classpathentry kind="lib" path="lib/apache-mime4j-0.6.jar"/>
+ <classpathentry kind="lib" path="lib/commons-fileupload-1.2.2.jar"/>
++ <classpathentry kind="lib" path="lib/json-simple-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/xercesImpl.jar"/>
+ <classpathentry kind="lib" path="lib/xml-apis.jar"/>
+ <classpathentry kind="lib" path="lib/geronimo-stax-api_1.0_spec-1.0.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-compress-1.4.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
- <classpathentry kind="lib" path="lib/servlet-api-2.5-20081211.jar"/>
++ <classpathentry kind="lib" path="lib/javax.servlet-3.0.0.v201112011016.jar"/>
+ <classpathentry kind="lib" path="lib/jaudiotagger-2.0.4-20111207.115108-15.jar"/>
+ <classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
+ <classpathentry kind="lib" path="lib/spatial4j-0.3.jar"/>
+ <classpathentry kind="lib" path="lib/jcl-over-slf4j-1.7.2.jar"/>
+ <classpathentry kind="lib" path="lib/slf4j-api-1.7.2.jar"/>
+ <classpathentry kind="lib" path="lib/zookeeper-3.4.5.jar"/>
++ <classpathentry kind="lib" path="lib/guava-15.0.jar"/>
+ <classpathentry kind="lib" path="lib/wstx-asl-3.2.9.jar"/>
+ <classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.2.jar"/>
+ <classpathentry kind="lib" path="lib/log4j-over-slf4j-1.7.2.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.3.1.jar"/>
+ <classpathentry kind="lib" path="lib/httpcore-4.3.jar"/>
+ <classpathentry kind="lib" path="lib/httpmime-4.3.1.jar"/>
+ <classpathentry kind="lib" path="lib/noggit-0.5.jar"/>
+ <classpathentry kind="lib" path="lib/metadata-extractor-2.6.2.jar"/>
+ <classpathentry kind="lib" path="lib/jcifs-1.3.17.jar"/>
++ <classpathentry kind="lib" path="lib/fontbox-1.8.3.jar"/>
++ <classpathentry kind="lib" path="lib/jempbox-1.8.3.jar"/>
++ <classpathentry kind="lib" path="lib/pdfbox-1.8.3.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-analyzers-common-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-analyzers-phonetic-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-classification-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-codecs-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-core-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-facet-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-grouping-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-highlighter-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-join-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-memory-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-misc-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-queries-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-queryparser-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-spatial-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-suggest-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/solr-core-4.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/solr-solrj-4.6.0.jar"/>
- <classpathentry kind="lib" path="lib/fontbox-1.8.3.jar"/>
- <classpathentry kind="lib" path="lib/jempbox-1.8.3.jar"/>
- <classpathentry kind="lib" path="lib/pdfbox-1.8.3.jar"/>
- <classpathentry kind="lib" path="lib/jsch-0.1.50.jar"/>
- <classpathentry kind="lib" path="lib/json-simple-1.1.1.jar"/>
- <classpathentry kind="lib" path="lib/guava-15.0.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="lib" path="lib/icu4j-core.jar"/>
+ <classpathentry kind="lib" path="lib/htmllexer.jar"/>
+ <classpathentry kind="lib" path="lib/jena-2.6.4.jar"/>
+ <classpathentry kind="lib" path="lib/sax-2.0.1.jar"/>
+ <classpathentry kind="lib" path="lib/arq-2.8.7.jar"/>
+ <classpathentry kind="lib" path="lib/iri-0.8.jar"/>
+ <classpathentry kind="lib" path="lib/jsoup-1.6.3.jar"/>
+ <classpathentry kind="output" path="gen"/>
+ </classpath>
diff --cc addon/YaCy.app/Contents/Info.plist
index db0dac042,0def7a93e..e30ebf920
--- a/addon/YaCy.app/Contents/Info.plist
+++ b/addon/YaCy.app/Contents/Info.plist
@@@ -99,10 -89,11 +98,10 @@@
<string>$JAVAROOT/lib/poi-3.6-20091214.jar</string>
<string>$JAVAROOT/lib/poi-scratchpad-3.6-20091214.jar</string>
<string>$JAVAROOT/lib/sax-2.0.1.jar</string>
- <string>$JAVAROOT/lib/servlet-api-2.5-20081211.jar</string>
<string>$JAVAROOT/lib/slf4j-api-1.7.2.jar</string>
<string>$JAVAROOT/lib/slf4j-jdk14-1.7.2.jar</string>
- <string>$JAVAROOT/lib/solr-core-4.5.0.jar</string>
- <string>$JAVAROOT/lib/solr-solrj-4.5.0.jar</string>
+ <string>$JAVAROOT/lib/solr-core-4.6.0.jar</string>
+ <string>$JAVAROOT/lib/solr-solrj-4.6.0.jar</string>
<string>$JAVAROOT/lib/spatial4j-0.3.jar</string>
<string>$JAVAROOT/lib/webcat-0.1-swf.jar</string>
<string>$JAVAROOT/lib/wstx-asl-3.2.9.jar</string>
diff --cc build.xml
index 4b1ea5036,479923de3..040eae768
--- a/build.xml
+++ b/build.xml
@@@ -226,10 -214,11 +225,10 @@@
<pathelement location="${lib}/poi-3.6-20091214.jar" />
<pathelement location="${lib}/poi-scratchpad-3.6-20091214.jar" />
<pathelement location="${lib}/sax-2.0.1.jar" />
- <pathelement location="${lib}/servlet-api-2.5-20081211.jar" />
<pathelement location="${lib}/slf4j-api-1.7.2.jar" />
<pathelement location="${lib}/slf4j-jdk14-1.7.2.jar" />
- <pathelement location="${lib}/solr-core-4.5.0.jar" />
- <pathelement location="${lib}/solr-solrj-4.5.0.jar" />
+ <pathelement location="${lib}/solr-core-4.6.0.jar" />
+ <pathelement location="${lib}/solr-solrj-4.6.0.jar" />
<pathelement location="${lib}/spatial4j-0.3.jar" />
<pathelement location="${lib}/webcat-0.1-swf.jar" />
<pathelement location="${lib}/wstx-asl-3.2.9.jar" />
diff --cc source/net/yacy/cora/federate/solr/SolrServlet.java
index 200dd66ce,a5651fc86..2eb72f8dc
--- a/source/net/yacy/cora/federate/solr/SolrServlet.java
+++ b/source/net/yacy/cora/federate/solr/SolrServlet.java
@@@ -1,255 -1,224 +1,231 @@@
- /**
- * SolrServlet
- * Copyright 2012 by Michael Peter Christen
- * First released 23.08.2012 at http://yacy.net
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program in the file lgpl21.txt
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
- package net.yacy.cora.federate.solr;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStreamWriter;
- import java.io.PrintWriter;
- import java.io.StringWriter;
- import java.io.Writer;
- import java.net.URL;
- import java.util.HashMap;
- import java.util.Map;
-
- import javax.servlet.Filter;
- import javax.servlet.FilterChain;
- import javax.servlet.FilterConfig;
- import javax.servlet.ServletException;
- import javax.servlet.ServletRequest;
- import javax.servlet.ServletResponse;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
-
- import net.yacy.cora.document.encoding.UTF8;
- import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;
- import net.yacy.cora.federate.solr.responsewriter.EnhancedXMLResponseWriter;
- import net.yacy.cora.federate.solr.responsewriter.GrepHTMLResponseWriter;
- import net.yacy.cora.federate.solr.responsewriter.HTMLResponseWriter;
- import net.yacy.cora.federate.solr.responsewriter.OpensearchResponseWriter;
- import net.yacy.cora.federate.solr.responsewriter.YJsonResponseWriter;
- import net.yacy.cora.util.ConcurrentLog;
- import net.yacy.search.Switchboard;
- import net.yacy.search.query.AccessTracker;
- import net.yacy.search.query.SearchEvent;
- import net.yacy.search.schema.CollectionSchema;
- import net.yacy.search.schema.WebgraphSchema;
-
- 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.MultiMapSolrParams;
- import org.apache.solr.core.SolrCore;
- import org.apache.solr.request.SolrQueryRequest;
- import org.apache.solr.request.SolrRequestInfo;
- import org.apache.solr.response.BinaryResponseWriter;
- import org.apache.solr.response.QueryResponseWriter;
- import org.apache.solr.response.ResultContext;
- import org.apache.solr.response.SolrQueryResponse;
- import org.apache.solr.servlet.SolrRequestParsers;
- import org.apache.solr.servlet.cache.HttpCacheHeaderUtil;
- import org.apache.solr.servlet.cache.Method;
- import org.apache.solr.util.FastWriter;
-
-
- public class SolrServlet implements Filter {
-
- private static EmbeddedSolrConnector connector;
- private final Map<String, QueryResponseWriter> RESPONSE_WRITER = new HashMap<String, QueryResponseWriter>();
-
- public SolrServlet() {
- }
-
- @Override
- public void init(FilterConfig config) throws ServletException {
-
- OpensearchResponseWriter opensearchResponseWriter = new OpensearchResponseWriter();
-
- // xml and xslt reponseWriter included in SorlCore.DEFAULT_RESPONSE_WRITERS
- // DEFAULT_RESPONSE_WRITERS is allways checke, here only additional response writers
- RESPONSE_WRITER.put("exml", new EnhancedXMLResponseWriter());
- RESPONSE_WRITER.put("html", new HTMLResponseWriter());
- RESPONSE_WRITER.put("grephtml", new GrepHTMLResponseWriter());
- RESPONSE_WRITER.put("rss", opensearchResponseWriter); //try http://localhost:8090/solr/select?wt=rss&q=olympia&hl=true&hl.fl=text_t,h1,h2
- RESPONSE_WRITER.put("opensearch", opensearchResponseWriter); //try http://localhost:8090/solr/select?wt=rss&q=olympia&hl=true&hl.fl=text_t,h1,h2
- RESPONSE_WRITER.put("yjson", new YJsonResponseWriter()); //try http://localhost:8090/solr/select?wt=json&q=olympia&hl=true&hl.fl=text_t,h1,h2
- // GSA response implemented in separate servlet
- // RESPONSE_WRITER.put("gsa", new GSAResponseWriter());
- }
-
- @Override
- public void destroy() {
-
- }
-
- @Override
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
-
- if (!(request instanceof HttpServletRequest)) {
- if (chain != null) chain.doFilter(request, response);
- return;
- }
-
- HttpServletRequest hrequest = (HttpServletRequest) request;
- HttpServletResponse hresponse = (HttpServletResponse) response;
-
- // check if this servlet was called correctly
- String pathInfo = hrequest.getPathInfo();
- String path = pathInfo == null ? hrequest.getServletPath() : hrequest.getServletPath() + pathInfo; // should be "/select" after this
-
- if (!EmbeddedSolrConnector.SELECT.equals(path)) {
- // this is not for this servlet
- if (chain != null) chain.doFilter(request, response);
- return;
- }
- if (!EmbeddedSolrConnector.CONTEXT.equals(hrequest.getContextPath())) {
- // this is not for this servlet
- if (chain != null) chain.doFilter(request, response);
- return;
- }
-
- // reject POST which is not supported here
- final Method reqMethod = Method.getMethod(hrequest.getMethod());
- if (reqMethod == null || (reqMethod != Method.GET && reqMethod != Method.HEAD)) {
- throw new ServletException("Unsupported method: " + hrequest.getMethod());
- }
-
-
- // prepare request to solr
- MultiMapSolrParams mmsp = SolrRequestParsers.parseQueryString(hrequest.getQueryString());
- String corename = mmsp.get("core",CollectionSchema.CORE_NAME);
-
- // get the embedded connector
- boolean defaultConnector = corename.equals(CollectionSchema.CORE_NAME);
- connector = defaultConnector ? Switchboard.getSwitchboard().index.fulltext().getDefaultEmbeddedConnector() : Switchboard.getSwitchboard().index.fulltext().getEmbeddedConnector(WebgraphSchema.CORE_NAME);
-
- SolrCore core = connector.getCore();
- if (core == null) {
- hresponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "core not initialized");
- return;
- }
-
- hrequest.setAttribute("org.apache.solr.CoreContainer", core);
- String wt = mmsp.get(CommonParams.WT, "xml"); // maybe use /solr/select?q=*:*&start=0&rows=10&wt=exml
- QueryResponseWriter responseWriter = RESPONSE_WRITER.get(wt); // check local response writer
- if (responseWriter == null) {
- // check default response writer
- responseWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(wt);
- if (responseWriter == null) {
- hresponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Solr responsewriter not found for " + wt);
- return;
+ /**
+ * SolrServlet
+ * Copyright 2012 by Michael Peter Christen
+ * First released 23.08.2012 at http://yacy.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ package net.yacy.cora.federate.solr;
+
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.OutputStreamWriter;
+ import java.io.PrintWriter;
+ import java.io.StringWriter;
+ import java.io.Writer;
+ import java.net.URL;
+ import java.util.Iterator;
+ import java.util.Map;
+
+ import javax.servlet.Filter;
+ import javax.servlet.FilterChain;
+ import javax.servlet.FilterConfig;
+ import javax.servlet.ServletException;
+ import javax.servlet.ServletRequest;
+ import javax.servlet.ServletResponse;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+
+ import net.yacy.cora.document.encoding.UTF8;
+ import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;
+
+ import org.apache.solr.common.SolrException;
+ import org.apache.solr.common.params.MultiMapSolrParams;
+ import org.apache.solr.core.SolrCore;
+ import org.apache.solr.request.SolrQueryRequest;
+ import org.apache.solr.request.SolrRequestInfo;
++import org.apache.solr.response.BinaryResponseWriter;
+ import org.apache.solr.response.QueryResponseWriter;
+ import org.apache.solr.response.SolrQueryResponse;
+ import org.apache.solr.response.XMLResponseWriter;
+ import org.apache.solr.search.DocIterator;
+ import org.apache.solr.search.DocList;
+ import org.apache.solr.search.SolrIndexSearcher;
+ import org.apache.solr.servlet.SolrRequestParsers;
+ import org.apache.solr.servlet.cache.HttpCacheHeaderUtil;
+ import org.apache.solr.servlet.cache.Method;
+ import org.apache.solr.util.FastWriter;
+
+ /*
+ * taken from the Solr 3.6.0 code, which is now deprecated;
+ * this is now done in Solr 4.x.x with org.apache.solr.servlet.SolrDispatchFilter
+ */
+ public class SolrServlet implements Filter {
+
+ private static final QueryResponseWriter responseWriter = new XMLResponseWriter();
+ private static EmbeddedSolrConnector connector;
+
+ public SolrServlet() {
+ }
+
+ public static void initCore(EmbeddedSolrConnector c) {
+ connector = c;
+ }
+
+ @Override
+ public void init(FilterConfig config) throws ServletException {
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+
+ if (!(request instanceof HttpServletRequest)) {
+ if (chain != null) chain.doFilter(request, response);
+ return;
+ }
+
+ HttpServletRequest hrequest = (HttpServletRequest) request;
+ HttpServletResponse hresponse = (HttpServletResponse) response;
+ SolrQueryRequest req = null;
+
+ // check if this servlet was called correctly
+ String pathInfo = hrequest.getPathInfo();
+ String path = pathInfo == null ? hrequest.getServletPath() : hrequest.getServletPath() + pathInfo; // should be "/select" after this
+
+ if (!EmbeddedSolrConnector.SELECT.equals(path)) {
+ // this is not for this servlet
+ if (chain != null) chain.doFilter(request, response);
+ return;
+ }
+ if (!EmbeddedSolrConnector.CONTEXT.equals(hrequest.getContextPath())) {
+ // this is not for this servlet
+ if (chain != null) chain.doFilter(request, response);
+ return;
+ }
+
+ // reject POST which is not supported here
+ final Method reqMethod = Method.getMethod(hrequest.getMethod());
+ if (reqMethod == null || (reqMethod != Method.GET && reqMethod != Method.HEAD)) {
+ throw new ServletException("Unsupported method: " + hrequest.getMethod());
+ }
+
+ Writer out = null;
+ try {
+ SolrCore core = connector.getCore();
+ if (core == null) {
+ throw new UnsupportedOperationException("core not initialized");
+ }
+
+ // prepare request to solr
+ hrequest.setAttribute("org.apache.solr.CoreContainer", core);
+ MultiMapSolrParams mmsp = SolrRequestParsers.parseQueryString(hrequest.getQueryString());
+ req = connector.request(mmsp);
+
+ SolrQueryResponse rsp = connector.query(req);
+
+ // prepare response
+ hresponse.setHeader("Cache-Control", "no-cache");
+ HttpCacheHeaderUtil.checkHttpCachingVeto(rsp, hresponse, reqMethod);
+
+ // check error
+ if (rsp.getException() != null) {
+ sendError(hresponse, rsp.getException());
+ return;
+ }
+
+ // write response header
+ final String contentType = responseWriter.getContentType(req, rsp);
+ if (null != contentType) response.setContentType(contentType);
+
+ if (Method.HEAD == reqMethod) {
+ return;
+ }
-
- // write response body
- out = new FastWriter(new OutputStreamWriter(response.getOutputStream(), UTF8.charset));
-
++
++ // write response body
++ if (responseWriter instanceof BinaryResponseWriter) {
++ ((BinaryResponseWriter) responseWriter).write(response.getOutputStream(), req, rsp);
++ } else {
++ out = new FastWriter(new OutputStreamWriter(response.getOutputStream(), UTF8.charset));
++ responseWriter.write(out, req, rsp);
++ out.flush();
+ }
- }
- Map<String,String[]> map = mmsp.getMap(); // get modifiable parameter map
- // add default search field if missing (required by edismax)
- if (!map.containsKey(CommonParams.DF)) map.put (CommonParams.DF, new String[]{CollectionSchema.text_t.getSolrFieldName()});
- // if this is a call to YaCys special search formats, enhance the query with field assignments
- if ((responseWriter instanceof YJsonResponseWriter || responseWriter instanceof OpensearchResponseWriter) && "true".equals(mmsp.get("hl", "true"))) {
- // add options for snippet generation
- if (!map.containsKey("hl.q")) map.put("hl.q",new String[]{mmsp.get("q")});
- if (!map.containsKey("hl.fl")) map.put("hl.fl",new String[]{CollectionSchema.h1_txt.getSolrFieldName() + "," + CollectionSchema.h2_txt.getSolrFieldName() + "," + CollectionSchema.text_t.getSolrFieldName()});
- if (!map.containsKey("hl.alternateField")) map.put("hl.alternateField",new String[]{CollectionSchema.description_txt.getSolrFieldName()});
- if (!map.containsKey("hl.simple.pre")) map.put("hl.simple.pre",new String[]{"<b>"});
- if (!map.containsKey("hl.simple.post")) map.put("hl.simple.post",new String[]{"</b>"});
- if (!map.containsKey("hl.fragsize")) map.put("hl.fragsize",new String[]{Integer.toString(SearchEvent.SNIPPET_MAX_LENGTH)});
- }
- SolrQueryRequest req = connector.request(mmsp);
- SolrQueryResponse rsp = connector.query(req);
-
- // prepare response
- hresponse.setHeader("Cache-Control", "no-cache");
- HttpCacheHeaderUtil.checkHttpCachingVeto(rsp, hresponse, reqMethod);
-
- // check error
- if (rsp.getException() != null) {
- sendError(hresponse, rsp.getException());
- return;
- }
-
- // write response header
- final String contentType = responseWriter.getContentType(req, rsp);
- if (null != contentType) response.setContentType(contentType);
-
- if (Method.HEAD == reqMethod) {
- return;
- }
-
- // write response body
- if (responseWriter instanceof BinaryResponseWriter) {
- ((BinaryResponseWriter) responseWriter).write(response.getOutputStream(), req, rsp);
- } else {
- Writer out = new FastWriter(new OutputStreamWriter(response.getOutputStream(), UTF8.charset));
- responseWriter.write(out, req, rsp);
- out.flush();
- }
-
- // log result
- Object rv = rsp.getValues().get("response");
- int matches = 0;
- if (rv != null && rv instanceof ResultContext) {
- matches = ((ResultContext) rv).docs.matches();
- } else if (rv != null && rv instanceof SolrDocumentList) {
- matches = (int) ((SolrDocumentList) rv).getNumFound();
- }
- AccessTracker.addToDump(mmsp.get("q"), Integer.toString(matches));
- ConcurrentLog.info("SOLR Query", "results: " + matches + ", for query:" + req.getParamString());
- req.close();
-
- SolrRequestInfo.clearRequestInfo();
- }
-
- private static void sendError(HttpServletResponse hresponse, Throwable ex) throws IOException {
- int code = (ex instanceof SolrException) ? ((SolrException) ex).code() : 500;
- StringWriter sw = new StringWriter();
- ex.printStackTrace(new PrintWriter(sw));
- hresponse.sendError((code < 100) ? 500 : code, ex.getMessage() + "\n\n" + sw.toString());
- }
-
- public static void waitForSolr(String context, int port) throws Exception {
- // A raw term query type doesn't check the schema
- URL url = new URL("http://127.0.0.1:" + port + context + "/select?q={!raw+f=test_query}ping");
-
- Exception ex=null;
- // Wait for a total of 20 seconds: 100 tries, 200 milliseconds each
- for (int i = 0; i < 600; i++) {
- try {
- InputStream stream = url.openStream();
- stream.close();
- } catch (final IOException e) {
- ex=e;
- Thread.sleep(200);
- continue;
- }
- return;
- }
- throw new RuntimeException("Jetty/Solr unresponsive", ex);
- }
-
- public static class Servlet404 extends HttpServlet {
- private static final long serialVersionUID=-4497069674942245148L;
- @Override
- public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
- res.sendError(HttpServletResponse.SC_NOT_FOUND, "Can not find: " + req.getRequestURI());
- }
- }
-
- }
++
+ //debug
+ @SuppressWarnings("unchecked")
+ Iterator<Map.Entry<String, Object>> ie = rsp.getValues().iterator();
+ Map.Entry<String, Object> e;
+ while (ie.hasNext()) {
+ e = ie.next();
+ System.out.println("Field: " + e.getKey() + ", value: " + e.getValue().getClass().getName());
+ //Field: responseHeader, value: org.apache.solr.common.util.SimpleOrderedMap
+ //Field: response, value: org.apache.solr.search.DocSlice
+ if (e.getValue() instanceof DocList) {
+ DocList ids = (DocList) e.getValue();
+ SolrIndexSearcher searcher = req.getSearcher();
+ DocIterator iterator = ids.iterator();
+ int sz = ids.size();
+ for (int i = 0; i < sz; i++) {
+ int id = iterator.nextDoc();
+ searcher.doc(id);
+ }
+ }
+ }
+
+ responseWriter.write(out, req, rsp);
+ out.flush();
+ } catch (final Throwable ex) {
+ sendError(hresponse, ex);
+ } finally {
+ if (req != null) {
+ req.close();
+ }
+ SolrRequestInfo.clearRequestInfo();
+ if (out != null) try {out.close();} catch (final IOException e1) {}
+ }
+ }
+
+ private static void sendError(HttpServletResponse hresponse, Throwable ex) throws IOException {
+ int code = (ex instanceof SolrException) ? ((SolrException) ex).code() : 500;
+ StringWriter sw = new StringWriter();
+ ex.printStackTrace(new PrintWriter(sw));
+ hresponse.sendError((code < 100) ? 500 : code, ex.getMessage() + "\n\n" + sw.toString());
+ }
+
+ public static void waitForSolr(String context, int port) throws Exception {
+ // A raw term query type doesn't check the schema
+ URL url = new URL("http://127.0.0.1:" + port + context + "/select?q={!raw+f=test_query}ping");
+
+ Exception ex=null;
+ // Wait for a total of 20 seconds: 100 tries, 200 milliseconds each
+ for (int i = 0; i < 600; i++) {
+ try {
+ InputStream stream = url.openStream();
+ stream.close();
+ } catch (final IOException e) {
+ ex=e;
+ Thread.sleep(200);
+ continue;
+ }
+ return;
+ }
+ throw new RuntimeException("Jetty/Solr unresponsive", ex);
+ }
+
+ public static class Servlet404 extends HttpServlet {
+ private static final long serialVersionUID=-4497069674942245148L;
+ @Override
+ public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
+ res.sendError(404, "Can not find: " + req.getRequestURI());
+ }
+ }
+
+ }
diff --cc source/net/yacy/http/GSAsearchServlet.java
index c0730680a,000000000..9e5b76b86
mode 100644,000000..100644
--- a/source/net/yacy/http/GSAsearchServlet.java
+++ b/source/net/yacy/http/GSAsearchServlet.java
@@@ -1,249 -1,0 +1,251 @@@
+/**
+ * search
+ * Copyright 2012 by Michael Peter Christen, [email protected], Frankfurt am Main, Germany
+ * First released 30.10.2013 at http://yacy.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.yacy.http;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Map;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.yacy.cora.date.ISO8601Formatter;
+import net.yacy.cora.document.encoding.UTF8;
+import net.yacy.cora.federate.solr.Ranking;
+import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;
+import net.yacy.cora.federate.solr.responsewriter.GSAResponseWriter;
+import net.yacy.cora.protocol.HeaderFramework;
+import net.yacy.cora.util.ConcurrentLog;
+import net.yacy.search.Switchboard;
+import net.yacy.search.query.AccessTracker;
+import net.yacy.search.query.QueryGoal;
+import net.yacy.search.query.QueryModifier;
+import net.yacy.search.query.SearchEvent;
+import net.yacy.search.schema.CollectionSchema;
+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.request.SolrQueryRequest;
+import org.apache.solr.request.SolrRequestInfo;
+import org.apache.solr.response.QueryResponseWriter;
+import org.apache.solr.response.ResultContext;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.util.FastWriter;
+
+
+/**
+ * This is a gsa result formatter for solr search results.
+ * The result format is implemented according to
+ * https://developers.google.com/search-appliance/documentation/68/xml_reference#results_xml
+ */
+public class GSAsearchServlet extends HttpServlet {
+
++ private static final long serialVersionUID = 7835985518515673885L;
++
+ private final static GSAResponseWriter responseWriter = new GSAResponseWriter();
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doGet(request, response);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType(QueryResponseWriter.CONTENT_TYPE_XML_UTF8);
+ response.setStatus(HttpServletResponse.SC_OK);
+ respond(request, Switchboard.getSwitchboard(), response.getOutputStream());
+ }
+
+ // ------------------------------------------
+ /**
+ * from here copy of htroot/gsa/gsasearchresult.java
+ * with modification to use HttpServletRequest instead of (yacy) RequestHeader
+ */
+
+
+ public static void respond(final HttpServletRequest header, final Switchboard sb, final OutputStream out) {
+
+ // remember the peer contact for peer statistics
+ String clientip = header.getHeader(HeaderFramework.CONNECTION_PROP_CLIENTIP);
+ if (clientip == null) clientip = "<unknown>"; // read an artificial header addendum
+ String userAgent = header.getHeader(HeaderFramework.USER_AGENT);
+ if (userAgent == null) userAgent = "<unknown>";
+ sb.peers.peerActions.setUserAgent(clientip, userAgent);
+
+ // --- handled by Servlet securityHandler
+ // check if user is allowed to search (can be switched in /ConfigPortal.html)
+ boolean authenticated = header.isUserInRole("admin"); //sb.adminAuthenticated(header) >= 2;
+ // final boolean searchAllowed = authenticated || sb.getConfigBool("publicSearchpage", true);
+ // if (!searchAllowed) return null;
+
+ // create post
+ serverObjects post = new serverObjects();
+ post.put("q", ""); post.put("num", "0");
+ // convert servletrequest parameter to old style serverObjects map
+ Map<String, String[]> map = header.getParameterMap();
+ Iterator<Map.Entry<String, String[]>> it = map.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, String[]> param = it.next();
+ post.put(param.getKey(), param.getValue()); // hint: post.put uses String[] for String value anyways
+ }
+
+ ConcurrentLog.info("GSA Query", post.toString());
+ sb.intermissionAllThreads(3000); // tell all threads to do nothing for a specific time
+
+ // rename post fields according to result style
+ //post.put(CommonParams.Q, post.remove("q")); // same as solr
+ //post.put(CommonParams.START, post.remove("start")); // same as solr
+ //post.put(, post.remove("client"));//required, example: myfrontend
+ //post.put(, post.remove("output"));//required, example: xml,xml_no_dtd
+ String originalQuery = post.get(CommonParams.Q, "");
+ post.put("originalQuery", originalQuery);
+
+ // get a solr query string
+ QueryGoal qg = new QueryGoal(originalQuery, originalQuery);
+ StringBuilder solrQ = qg.collectionTextQueryString(sb.index.fulltext().getDefaultConfiguration(), 0, false);
+ post.put("defType", "edismax");
+ post.put(CommonParams.Q, solrQ.toString());
+ post.put(CommonParams.ROWS, post.remove("num"));
+ post.put(CommonParams.ROWS, Math.min(post.getInt(CommonParams.ROWS, 10), (authenticated) ? 100000000 : 100));
+
+ // 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);
+ 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.endsWith("..") ? new String[]{dr.substring(0, dr.length() - 2), ""} : dr.startsWith("..") ? new String[]{"", dr.substring(2)} : dr.split("\\.\\.");
+ if (from_to.length != 2) continue;
+ Date from = HeaderFramework.parseGSAFS(from_to[0]);
+ if (from == null) from = new Date(0);
+ Date to = HeaderFramework.parseGSAFS(from_to[1]);
+ if (to == null) to = new Date();
+ to.setTime(to.getTime() + 24L * 60L * 60L * 1000L); // we add a day because the day is inclusive
+ 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() + ',' +
+ CollectionSchema.sku.getSolrFieldName() + ',' +
+ CollectionSchema.title.getSolrFieldName() + ',' +
+ CollectionSchema.description_txt.getSolrFieldName() + ',' +
+ CollectionSchema.load_date_dt.getSolrFieldName() + ',' +
+ CollectionSchema.last_modified.getSolrFieldName() + ',' +
+ CollectionSchema.size_i.getSolrFieldName());
+ post.put("hl", "true");
+ post.put("hl.q", originalQuery);
+ post.put("hl.fl", CollectionSchema.h1_txt.getSolrFieldName() + "," + CollectionSchema.h2_txt.getSolrFieldName() + "," + CollectionSchema.text_t.getSolrFieldName());
+ post.put("hl.alternateField", CollectionSchema.description_txt.getSolrFieldName());
+ post.put("hl.simple.pre", "<b>");
+ post.put("hl.simple.post", "</b>");
+ post.put("hl.fragsize", Integer.toString(SearchEvent.SNIPPET_MAX_LENGTH));
+
+ //String[] access = post.remove("access");
+ //String[] entqr = post.remove("entqr");
+
+ // add sites operator
+ String[] site = post.remove("site"); // example: col1|col2
+ 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 + ")");
+ }
+
+ // get the embedded connector
+ EmbeddedSolrConnector connector = sb.index.fulltext().getDefaultEmbeddedConnector();
+ if (connector == null) return;
+
+ // do the solr request
+ SolrQueryRequest req = connector.request(post.toSolrParams(null));
+ SolrQueryResponse response = null;
+ Exception e = null;
+ try {response = connector.query(req);} catch (final SolrException ee) {e = ee;}
+ if (response != null) e = response.getException();
+ if (e != null) {
+ ConcurrentLog.logException(e);
+ if (req != null) req.close();
+ SolrRequestInfo.clearRequestInfo();
+ return;
+ }
+
+ // set some context for the writer
+ /*
+ Map<Object,Object> context = req.getContext();
+ context.put("ip", header.get("CLIENTIP", ""));
+ context.put("client", "vsm_frontent");
+ context.put("sort", sort.sort);
+ 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 stream
+ Writer ow = new FastWriter(new OutputStreamWriter(out, UTF8.charset));
+ try {
+ responseWriter.write(ow, req, response);
+ ow.flush();
+ } catch (final IOException e1) {
+ } finally {
+ req.close();
+ SolrRequestInfo.clearRequestInfo();
+ try {ow.close();} catch (final IOException e1) {}
+ }
+
+ // log result
+ Object rv = response.getValues().get("response");
+ int matches = 0;
+ if (rv != null && rv instanceof ResultContext) {
+ matches = ((ResultContext) rv).docs.matches();
+ } else if (rv != null && rv instanceof SolrDocumentList) {
+ matches = (int) ((SolrDocumentList) rv).getNumFound();
+ }
+ AccessTracker.addToDump(originalQuery, Integer.toString(matches));
+ ConcurrentLog.info("GSA Query", "results: " + matches + ", for query:" + post.toString());
+ }
+}