From 870aedf3c6d55536e2f176c6737f9ecc60e472ab Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 20 Mar 2013 16:19:49 +0100 Subject: [PATCH] fixes for better search interface integration in yaml templates --- htroot/solr/select.java | 11 ++++++----- htroot/yacysearch.java | 4 ++-- .../solr/responsewriter/JsonResponseWriter.java | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htroot/solr/select.java b/htroot/solr/select.java index b39638fcf..1b1d2ba8c 100644 --- a/htroot/solr/select.java +++ b/htroot/solr/select.java @@ -177,11 +177,12 @@ public class select { // if this is a call to YaCys special search formats, enhance the query with field assignments if ((responseWriter instanceof JsonResponseWriter || responseWriter instanceof OpensearchResponseWriter) && "true".equals(post.get("hl", "true"))) { // add options for snippet generation - post.put("hl", "true"); - post.put("hl.fl", "text_t,h1,h2"); - post.put("hl.simple.pre", ""); - post.put("hl.simple.post", ""); - post.put("hl.fragsize", Integer.toString(SearchEvent.SNIPPET_MAX_LENGTH)); + if (!post.containsKey("hl.q")) post.put("hl.q", q); + if (!post.containsKey("hl.fl")) post.put("hl.fl", CollectionSchema.h1_txt.getSolrFieldName() + "," + CollectionSchema.h2_txt.getSolrFieldName() + "," + CollectionSchema.text_t.getSolrFieldName()); + if (!post.containsKey("hl.alternateField")) post.put("hl.alternateField", CollectionSchema.description.getSolrFieldName()); + if (!post.containsKey("hl.simple.pre")) post.put("hl.simple.pre", ""); + if (!post.containsKey("hl.simple.post")) post.put("hl.simple.post", ""); + if (!post.containsKey("hl.fragsize")) post.put("hl.fragsize", Integer.toString(SearchEvent.SNIPPET_MAX_LENGTH)); } // get the embedded connector diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index cfcd28a8d..46ec5dcb7 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -212,8 +212,8 @@ public class yacysearch { ? 100 : 5000) : (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline() ? 20 : 1000), - post.getInt("maximumRecords", post.getInt("count", 10))); // SRU syntax with old property as alternative - int startRecord = post.getInt("startRecord", post.getInt("offset", 0)); + post.getInt("maximumRecords", post.getInt("count", post.getInt("rows", 10)))); // SRU syntax with old property as alternative + int startRecord = post.getInt("startRecord", post.getInt("offset", post.getInt("start", 0))); boolean global = post.get("resource", "local").equals("global") && sb.peers.sizeConnected() > 0; final boolean indexof = (post != null && post.get("indexof", "").equals("on")); diff --git a/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.java index 9f14cf6d2..1dfd38d1c 100644 --- a/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.java +++ b/source/net/yacy/cora/federate/solr/responsewriter/JsonResponseWriter.java @@ -127,6 +127,7 @@ public class JsonResponseWriter implements QueryResponseWriter { SolrIndexSearcher searcher = request.getSearcher(); DocIterator iterator = response.iterator(); for (int i = 0; i < responseCount; i++) { + try { writer.write("{\n".toCharArray()); int id = iterator.nextDoc(); Document doc = searcher.doc(id, OpensearchResponseWriter.SOLR_FIELDS); @@ -216,6 +217,7 @@ public class JsonResponseWriter implements QueryResponseWriter { if (i < responseCount - 1) { writer.write(",\n".toCharArray()); } + } catch (Throwable ee) {} } writer.write("],\n".toCharArray()); @@ -233,7 +235,7 @@ public class JsonResponseWriter implements QueryResponseWriter { NamedList authors = facetFields == null ? null : (NamedList) facetFields.get(CollectionSchema.author_sxt.getSolrFieldName()); if (domains != null) { - writer.write("{\"facetname\":\"domains\",\"displayname\":\"Domains\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[\n".toCharArray()); + writer.write("{\"facetname\":\"domains\",\"displayname\":\"Provider\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[\n".toCharArray()); for (int i = 0; i < domains.size(); i++) { facetEntry(writer, "site", domains.getName(i), Integer.toString(domains.getVal(i))); if (i < domains.size() - 1) writer.write(',');