From 69b8d61c4725c686bb5fb618f0399b047bfb811b Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Tue, 12 Nov 2013 15:54:54 +0100 Subject: [PATCH] fix for search requests in GSA interface which contain 'funny' characters (like ':' etc.) --- htroot/gsa/searchresult.java | 2 +- source/net/yacy/search/query/QueryGoal.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/htroot/gsa/searchresult.java b/htroot/gsa/searchresult.java index 1a145cf94..e88714076 100644 --- a/htroot/gsa/searchresult.java +++ b/htroot/gsa/searchresult.java @@ -163,7 +163,7 @@ public class searchresult { CollectionSchema.last_modified.getSolrFieldName() + ',' + CollectionSchema.size_i.getSolrFieldName()); post.put("hl", "true"); - post.put("hl.q", originalQuery); + post.put("hl.q", qg.getIncludeString()); 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", ""); diff --git a/source/net/yacy/search/query/QueryGoal.java b/source/net/yacy/search/query/QueryGoal.java index 50861de59..51687a581 100644 --- a/source/net/yacy/search/query/QueryGoal.java +++ b/source/net/yacy/search/query/QueryGoal.java @@ -45,7 +45,7 @@ public class QueryGoal { private static char space = ' '; private static char sq = '\''; private static char dq = '"'; - private static String seps = ".,/&_"; + private static String seps = ".:;#'*`,!$%()=?^<>/&_"; private String query_original; private HandleSet include_hashes, exclude_hashes; @@ -165,6 +165,17 @@ public class QueryGoal { return exclude_hashes; } + /** + * the include string may be useful (and better) for highlight/snippet computation + * @return the query string containing only the positive literals (includes) and without whitespace characters + */ + public String getIncludeString() { + if (this.include_strings.size() == 0) return ""; + StringBuilder sb = new StringBuilder(10 * include_strings.size()); + for (String s: this.include_strings) sb.append(s).append(' '); + return sb.toString().substring(0, sb.length() - 1); + } + public ArrayList getIncludeStrings() { return include_strings; }