Skip to content

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

fix for search requests in GSA interface which contain 'funny' characters (like ':' etc.)

Michael Peter Christen69b8d61c4725
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", "<b>");
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<String> getIncludeStrings() {
return include_strings;
}