diff --git a/lib/commons-collections-3.2.2.jar b/lib/commons-collections-3.2.2.jar
new file mode 100644
index 000000000..fa5df82a6
Binary files /dev/null and b/lib/commons-collections-3.2.2.jar differ
diff --git a/lib/commons-collections4-4.1.License b/lib/commons-collections4-4.1.License
deleted file mode 100644
index d64569567..000000000
--- a/lib/commons-collections4-4.1.License
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/lib/commons-collections4-4.1.jar b/lib/commons-collections4-4.1.jar
deleted file mode 100644
index 43a9413b9..000000000
Binary files a/lib/commons-collections4-4.1.jar and /dev/null differ
diff --git a/lib/lucene-analyzers-common-6.6.6.jar b/lib/lucene-analyzers-common-7.7.3.jar
similarity index 54%
rename from lib/lucene-analyzers-common-6.6.6.jar
rename to lib/lucene-analyzers-common-7.7.3.jar
index 072d483cc..47b9b1374 100644
Binary files a/lib/lucene-analyzers-common-6.6.6.jar and b/lib/lucene-analyzers-common-7.7.3.jar differ
diff --git a/lib/lucene-analyzers-phonetic-6.6.6.jar b/lib/lucene-analyzers-phonetic-7.7.3.jar
similarity index 55%
rename from lib/lucene-analyzers-phonetic-6.6.6.jar
rename to lib/lucene-analyzers-phonetic-7.7.3.jar
index f0e7c463b..31bb241fc 100644
Binary files a/lib/lucene-analyzers-phonetic-6.6.6.jar and b/lib/lucene-analyzers-phonetic-7.7.3.jar differ
diff --git a/lib/lucene-backward-codecs-6.6.6.jar b/lib/lucene-backward-codecs-6.6.6.jar
deleted file mode 100644
index 00972fc40..000000000
Binary files a/lib/lucene-backward-codecs-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-backward-codecs-7.7.3.jar b/lib/lucene-backward-codecs-7.7.3.jar
new file mode 100644
index 000000000..4bfa858e6
Binary files /dev/null and b/lib/lucene-backward-codecs-7.7.3.jar differ
diff --git a/lib/lucene-classification-6.6.6.jar b/lib/lucene-classification-6.6.6.jar
deleted file mode 100644
index 9feef9ab2..000000000
Binary files a/lib/lucene-classification-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-classification-7.7.3.jar b/lib/lucene-classification-7.7.3.jar
new file mode 100644
index 000000000..b46656e5c
Binary files /dev/null and b/lib/lucene-classification-7.7.3.jar differ
diff --git a/lib/lucene-codecs-6.6.6.jar b/lib/lucene-codecs-6.6.6.jar
deleted file mode 100644
index 0f4779f44..000000000
Binary files a/lib/lucene-codecs-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-codecs-7.7.3.jar b/lib/lucene-codecs-7.7.3.jar
new file mode 100644
index 000000000..3b06aaa0e
Binary files /dev/null and b/lib/lucene-codecs-7.7.3.jar differ
diff --git a/lib/lucene-core-6.6.6.jar b/lib/lucene-core-6.6.6.jar
deleted file mode 100644
index 7c4bc3f6b..000000000
Binary files a/lib/lucene-core-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-core-7.7.3.jar b/lib/lucene-core-7.7.3.jar
new file mode 100644
index 000000000..463f757a6
Binary files /dev/null and b/lib/lucene-core-7.7.3.jar differ
diff --git a/lib/lucene-grouping-6.6.6.jar b/lib/lucene-grouping-6.6.6.jar
deleted file mode 100644
index 8855a3be8..000000000
Binary files a/lib/lucene-grouping-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-grouping-7.7.3.jar b/lib/lucene-grouping-7.7.3.jar
new file mode 100644
index 000000000..f84112ef9
Binary files /dev/null and b/lib/lucene-grouping-7.7.3.jar differ
diff --git a/lib/lucene-highlighter-6.6.6.jar b/lib/lucene-highlighter-6.6.6.jar
deleted file mode 100644
index a29b5b720..000000000
Binary files a/lib/lucene-highlighter-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-highlighter-7.7.3.jar b/lib/lucene-highlighter-7.7.3.jar
new file mode 100644
index 000000000..456dbb2cc
Binary files /dev/null and b/lib/lucene-highlighter-7.7.3.jar differ
diff --git a/lib/lucene-join-6.6.6.jar b/lib/lucene-join-6.6.6.jar
deleted file mode 100644
index 1b5dc691f..000000000
Binary files a/lib/lucene-join-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-join-7.7.3.jar b/lib/lucene-join-7.7.3.jar
new file mode 100644
index 000000000..50c041ccb
Binary files /dev/null and b/lib/lucene-join-7.7.3.jar differ
diff --git a/lib/lucene-memory-6.6.6.jar b/lib/lucene-memory-6.6.6.jar
deleted file mode 100644
index f3a56a40f..000000000
Binary files a/lib/lucene-memory-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-memory-7.7.3.jar b/lib/lucene-memory-7.7.3.jar
new file mode 100644
index 000000000..47c0d933f
Binary files /dev/null and b/lib/lucene-memory-7.7.3.jar differ
diff --git a/lib/lucene-misc-6.6.6.jar b/lib/lucene-misc-6.6.6.jar
deleted file mode 100644
index 52c406c90..000000000
Binary files a/lib/lucene-misc-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-misc-7.7.3.jar b/lib/lucene-misc-7.7.3.jar
new file mode 100644
index 000000000..604e76cd2
Binary files /dev/null and b/lib/lucene-misc-7.7.3.jar differ
diff --git a/lib/lucene-queries-6.6.6.jar b/lib/lucene-queries-6.6.6.jar
deleted file mode 100644
index bfd797fac..000000000
Binary files a/lib/lucene-queries-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-queries-7.7.3.jar b/lib/lucene-queries-7.7.3.jar
new file mode 100644
index 000000000..14a16ea89
Binary files /dev/null and b/lib/lucene-queries-7.7.3.jar differ
diff --git a/lib/lucene-queryparser-6.6.6.jar b/lib/lucene-queryparser-7.7.3.jar
similarity index 65%
rename from lib/lucene-queryparser-6.6.6.jar
rename to lib/lucene-queryparser-7.7.3.jar
index bfaf06f9d..e1f012f8f 100644
Binary files a/lib/lucene-queryparser-6.6.6.jar and b/lib/lucene-queryparser-7.7.3.jar differ
diff --git a/lib/lucene-spatial-extras-6.6.6.jar b/lib/lucene-spatial-extras-6.6.6.jar
deleted file mode 100644
index d31df9a3b..000000000
Binary files a/lib/lucene-spatial-extras-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-spatial-extras-7.7.3.jar b/lib/lucene-spatial-extras-7.7.3.jar
new file mode 100644
index 000000000..b2dc3253b
Binary files /dev/null and b/lib/lucene-spatial-extras-7.7.3.jar differ
diff --git a/lib/lucene-suggest-6.6.6.jar b/lib/lucene-suggest-6.6.6.jar
deleted file mode 100644
index 820cdea88..000000000
Binary files a/lib/lucene-suggest-6.6.6.jar and /dev/null differ
diff --git a/lib/lucene-suggest-7.7.3.jar b/lib/lucene-suggest-7.7.3.jar
new file mode 100644
index 000000000..6a0ac6f4a
Binary files /dev/null and b/lib/lucene-suggest-7.7.3.jar differ
diff --git a/lib/noggit-0.6.jar b/lib/noggit-0.6.jar
deleted file mode 100644
index c23e06fe4..000000000
Binary files a/lib/noggit-0.6.jar and /dev/null differ
diff --git a/lib/noggit-0.8.jar b/lib/noggit-0.8.jar
new file mode 100644
index 000000000..d530cd128
Binary files /dev/null and b/lib/noggit-0.8.jar differ
diff --git a/lib/rrd4j-3.2.jar b/lib/rrd4j-3.2.jar
new file mode 100644
index 000000000..233725662
Binary files /dev/null and b/lib/rrd4j-3.2.jar differ
diff --git a/lib/solr-core-6.6.6.jar b/lib/solr-core-6.6.6.jar
deleted file mode 100644
index 517bd5e38..000000000
Binary files a/lib/solr-core-6.6.6.jar and /dev/null differ
diff --git a/lib/solr-core-7.7.3.jar b/lib/solr-core-7.7.3.jar
new file mode 100644
index 000000000..6e8da4da7
Binary files /dev/null and b/lib/solr-core-7.7.3.jar differ
diff --git a/lib/solr-solrj-6.6.6.jar b/lib/solr-solrj-6.6.6.jar
deleted file mode 100644
index 948c42433..000000000
Binary files a/lib/solr-solrj-6.6.6.jar and /dev/null differ
diff --git a/lib/solr-solrj-7.7.3.jar b/lib/solr-solrj-7.7.3.jar
new file mode 100644
index 000000000..b95072e9b
Binary files /dev/null and b/lib/solr-solrj-7.7.3.jar differ
diff --git a/lib/zookeeper-3.4.10.jar b/lib/zookeeper-3.4.10.jar
deleted file mode 100644
index 0d8b0d312..000000000
Binary files a/lib/zookeeper-3.4.10.jar and /dev/null differ
diff --git a/lib/zookeeper-3.4.14.jar b/lib/zookeeper-3.4.14.jar
new file mode 100644
index 000000000..0b5620eee
Binary files /dev/null and b/lib/zookeeper-3.4.14.jar differ
diff --git a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java
index b7c417688..2e96e77f5 100644
--- a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java
+++ b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java
@@ -53,7 +53,6 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.SolrInfoMBean;
import org.apache.solr.handler.component.SearchHandler;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
@@ -122,10 +121,6 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
return 0;
}
- public Map getSolrInfoBeans() {
- return this.core.getInfoRegistry();
- }
-
@Override
public void clearCaches() {
SolrConfig solrConfig = this.core.getSolrConfig();
@@ -141,10 +136,6 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
@SuppressWarnings("unchecked")
SolrCache documentCache = solrConfig.documentCacheConfig == null ? null : solrConfig.documentCacheConfig.newInstance();
if (documentCache != null) documentCache.clear();
- for (SolrInfoMBean ib: this.core.getInfoRegistry().values()) {
- // clear 'lost' caches
- if (ib instanceof SolrCache) ((SolrCache,?>) ib).clear();
- }
}
public SolrInstance getInstance() {
@@ -405,7 +396,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
@Override
public long getCountByQuery(String querystring) {
- int numFound = 0;
+ long numFound = 0;
DocListSearcher docListSearcher = null;
try {
docListSearcher = new DocListSearcher(querystring, null, 0, 0, CollectionSchema.id.getSolrFieldName());
diff --git a/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java b/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java
index f16eabfed..fb5a07950 100644
--- a/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java
+++ b/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java
@@ -58,7 +58,6 @@ import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.update.UpdateShardHandler.IdleConnectionsEvictor;
import net.yacy.cora.document.id.MultiProtocolURL;
import net.yacy.cora.protocol.HeaderFramework;
@@ -97,20 +96,6 @@ public class RemoteInstance implements SolrInstance {
public static final AtomicBoolean ENABLE_SNI_EXTENSION = new AtomicBoolean(
Boolean.parseBoolean(System.getProperty("jsse.enableSNIExtension", Boolean.toString(ENABLE_SNI_EXTENSION_DEFAULT))));
- /**
- * Background daemon thread evicting expired idle connections from the pool.
- * This may be eventually already done by the pool itself on connection request,
- * but this background task helps when no request is made to the pool for a long
- * time period.
- */
- private static final IdleConnectionsEvictor EXPIRED_CONNECTIONS_EVICTOR = new IdleConnectionsEvictor(
- CONNECTION_MANAGER, DEFAULT_CONNECTION_EVICTOR_SLEEP_TIME, TimeUnit.SECONDS,
- DEFAULT_POOLED_CONNECTION_TIME_TO_LIVE, TimeUnit.SECONDS);
-
- static {
- EXPIRED_CONNECTIONS_EVICTOR.start();
- }
-
/** A custom scheme registry allowing https connections to servers using self-signed certificate */
private static final org.apache.http.conn.scheme.SchemeRegistry SCHEME_REGISTRY = buildTrustSelfSignedSchemeRegistry();
@@ -286,7 +271,7 @@ public class RemoteInstance implements SolrInstance {
params.set(HttpClientUtil.PROP_SO_TIMEOUT, this.timeout);
- this.client = HttpClientUtil.createClient(params, CONNECTION_MANAGER);
+ this.client = HttpClientUtil.createClient(params);
if(this.client instanceof org.apache.http.impl.client.DefaultHttpClient) {
if(this.client.getParams() != null) {
/* Set the maximum time to get a connection from the shared connections pool */
@@ -587,14 +572,6 @@ public class RemoteInstance implements SolrInstance {
*/
public static void closeConnectionManager() {
try {
- if (EXPIRED_CONNECTIONS_EVICTOR != null) {
- // Shut down the evictor thread
- EXPIRED_CONNECTIONS_EVICTOR.shutdown();
- try {
- EXPIRED_CONNECTIONS_EVICTOR.awaitTermination(1L, TimeUnit.SECONDS);
- } catch (final InterruptedException ignored) {
- }
- }
} finally {
if (CONNECTION_MANAGER != null) {
CONNECTION_MANAGER.shutdown();
diff --git a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java
deleted file mode 100644
index 6718b9b8e..000000000
--- a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java
+++ /dev/null
@@ -1,584 +0,0 @@
-/**
- * GSAResponseWriter
- * Copyright 2012 by Michael Peter Christen
- * First released 14.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 .
- */
-
-package net.yacy.cora.federate.solr.responsewriter;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.time.DateTimeException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexableField;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.XML;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.QueryResponseWriter;
-import org.apache.solr.response.ResultContext;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.search.DocIterator;
-import org.apache.solr.search.DocList;
-import org.apache.solr.search.SolrIndexSearcher;
-
-import net.yacy.cora.date.ISO8601Formatter;
-import net.yacy.cora.protocol.HeaderFramework;
-import net.yacy.cora.util.CommonPattern;
-import net.yacy.http.servlets.GSAsearchServlet;
-import net.yacy.peers.operation.yacyVersion;
-import net.yacy.search.Switchboard;
-import net.yacy.search.schema.CollectionSchema;
-
-/**
- * implementation of a GSA search result.
- * example: GET /gsa/searchresult?q=chicken+teriyaki&output=xml&client=test&site=test&sort=date:D:S:d1
- * for a xml reference, see https://developers.google.com/search-appliance/documentation/614/xml_reference
- */
-public class GSAResponseWriter implements QueryResponseWriter, SolrjResponseWriter {
-
- private static String YaCyVer = null;
- private static final char lb = '\n';
- private enum GSAToken {
- CACHE_LAST_MODIFIED, // Date that the document was crawled, as specified in the Date HTTP header when the document was crawled for this index.
- CRAWLDATE, // An optional element that shows the date when the page was crawled. It is shown only for pages that have been crawled within the past two days.
- U, // The URL of the search result.
- UE, // The URL-encoded version of the URL that is in the U parameter.
- GD, // Contains the description of a KeyMatch result..
- T, // The title of the search result.
- RK, // Provides a ranking number used internally by the search appliance.
- ENT_SOURCE, // Identifies the application ID (serial number) of the search appliance that contributes to a result. Example: S5-KUB000F0ADETLA
- FS, // Additional details about the search result.
- R, // details of an individual search result.
- S, // The snippet for the search result. Query terms appear in bold in the results. Line breaks are included for proper text wrapping.
- LANG, // Indicates the language of the search result. The LANG element contains a two-letter language code.
- HAS; // Encapsulates special features that are included for this search result.
- }
-
-
- private static final char[] XML_START = (
- "\n\n\n").toCharArray();
- private static final char[] XML_STOP = "\n".toCharArray();
-
- // pre-select a set of YaCy schema fields for the solr searcher which should cause a better caching
- private static final CollectionSchema[] extrafields = new CollectionSchema[]{
- CollectionSchema.id, CollectionSchema.sku, CollectionSchema.title, CollectionSchema.description_txt,
- CollectionSchema.last_modified, CollectionSchema.load_date_dt, CollectionSchema.size_i,
- CollectionSchema.language_s, CollectionSchema.collection_sxt
- };
-
- private static final Set SOLR_FIELDS = new HashSet<>();
- static {
-
- SOLR_FIELDS.add(CollectionSchema.language_s.getSolrFieldName());
- for (CollectionSchema field: extrafields) SOLR_FIELDS.add(field.getSolrFieldName());
- }
-
- private static class ResHead {
- public long offset, numFound;
- public int rows;
- //public int status, QTime;
- //public String df, q, wt;
- //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 = CommonPattern.DOUBLEPOINT.split(d);
- if (s.length < 1) return;
- this.action = s[0]; // date
- this.direction = s.length > 1 ? s[1] : "D"; // A or D
- this.mode = s.length > 2 ? s[2] : "S"; // S, R, L
- this.format = s.length > 3 ? s[3] : "d1"; // d1
- }
- public String toSolr() {
- if (this.action != null && "date".equals(this.action)) {
- return CollectionSchema.last_modified.getSolrFieldName() + " " + (("D".equals(this.direction) ? "desc" : "asc"));
- }
- return null;
- }
- }
-
- @Override
- public String getContentType(final SolrQueryRequest request, final SolrQueryResponse response) {
- return CONTENT_TYPE_XML_UTF8;
- }
-
- @Override
- public void init(@SuppressWarnings("rawtypes") NamedList n) {
- }
-
- @Override
- public void write(final Writer writer, final SolrQueryRequest request, final SolrQueryResponse rsp) throws IOException {
-
- final long start = System.currentTimeMillis();
-
- final Object responseObj = rsp.getResponse();
-
- if(responseObj instanceof ResultContext) {
- /* Regular response object */
-
- final DocList documents = ((ResultContext) responseObj).getDocList();
-
- final Object highlightingObj = rsp.getValues().get("highlighting");
- final Map> snippets = highlightingObj instanceof NamedList
- ? OpensearchResponseWriter.snippetsFromHighlighting((NamedList>) highlightingObj)
- : new HashMap<>();
-
- // parse response header
- final ResHead resHead = new ResHead();
- resHead.rows = request.getParams().getInt(CommonParams.ROWS, 0);
- resHead.offset = documents.offset(); // equal to 'start'
- resHead.numFound = documents.matches();
- //resHead.df = (String) val0.get("df");
- //resHead.q = (String) val0.get("q");
- //resHead.wt = (String) val0.get("wt");
- //resHead.status = (Integer) responseHeader.get("status");
- //resHead.QTime = (Integer) responseHeader.get("QTime");
- //resHead.maxScore = response.maxScore();
-
- // write header
- writeHeader(writer, request, resHead, start);
-
- // body introduction
- writeBodyIntro(writer, request, resHead, documents.size());
-
- writeDocs(writer, request, documents, snippets, resHead);
-
- writer.write(""); writer.write(lb);
- writer.write(XML_STOP);
- } else if(responseObj instanceof SolrDocumentList) {
- /*
- * The response object can be a SolrDocumentList when the response is partial,
- * for example when the allowed processing time has been exceeded
- */
- final SolrDocumentList documents = (SolrDocumentList) responseObj;
-
- final Object highlightingObj = rsp.getValues().get("highlighting");
- final Map> snippets = highlightingObj instanceof NamedList
- ? OpensearchResponseWriter.snippetsFromHighlighting((NamedList>) highlightingObj)
- : new HashMap<>();
-
- writeSolrDocumentList(writer, request, snippets, start, documents);
- } else {
- throw new IOException("Unable to process Solr response format");
- }
- }
-
- @Override
- public void write(Writer writer, SolrQueryRequest request, String coreName, QueryResponse rsp) throws IOException {
- final long start = System.currentTimeMillis();
-
- writeSolrDocumentList(writer, request, snippetsFromHighlighting(rsp.getHighlighting()), start,
- rsp.getResults());
- }
-
- /**
- * Produce snippets from Solr (they call that 'highlighting')
- *
- * @param sorlHighlighting highlighting from Solr
- * @return a map from urlhashes to a list of snippets for that url
- */
- private Map> snippetsFromHighlighting(
- final Map>> sorlHighlighting) {
- final Map> snippets = new HashMap<>();
- if (sorlHighlighting == null) {
- return snippets;
- }
- for (final Entry>> highlightingEntry : sorlHighlighting.entrySet()) {
- final String urlHash = highlightingEntry.getKey();
- final Map> highlights = highlightingEntry.getValue();
- final LinkedHashSet urlSnippets = new LinkedHashSet<>();
- for (final List texts : highlights.values()) {
- urlSnippets.addAll(texts);
- }
- snippets.put(urlHash, urlSnippets);
- }
- return snippets;
- }
-
- /**
- * Append to the writer a representation of a list of Solr documents. All
- * parameters are required and must not be null.
- *
- * @param writer an open output writer
- * @param request the Solr request
- * @param snippets the snippets computed from the Solr highlighting
- * @param start the results start index
- * @param documents the Solr documents to process
- * @throws IOException when a write error occurred
- */
- private void writeSolrDocumentList(final Writer writer, final SolrQueryRequest request,
- final Map> snippets, final long start, final SolrDocumentList documents)
- throws IOException {
-
- // parse response header
- final ResHead resHead = new ResHead();
- resHead.rows = request.getParams().getInt(CommonParams.ROWS, 0);
- resHead.offset = documents.getStart();
- resHead.numFound = documents.getNumFound();
-
- // write header
- writeHeader(writer, request, resHead, start);
-
- // body introduction
- writeBodyIntro(writer, request, resHead, documents.size());
-
- writeDocs(writer, documents, snippets, resHead, request.getParams().get("originalQuery"));
-
- writer.write(""); writer.write(lb);
- writer.write(XML_STOP);
- }
-
- /**
- * Append the response header to the writer. All parameters are required and
- * must not be null.
- *
- * @param writer an open output writer
- * @param request the Solr request
- * @param resHead results header information
- * @param startTime this writer processing start time in milliseconds since
- * Epoch
- * @throws IOException when a write error occurred
- */
- private void writeHeader(final Writer writer, final SolrQueryRequest request, final ResHead resHead,
- final long startTime) throws IOException {
- final Map