Skip to content

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

allow single quote " ' " in query see http://mantis.tokeek.de/view.php?id=379 -add QueryGoal test case for this

regere88537522d65
diff --git a/source/net/yacy/search/query/QueryGoal.java b/source/net/yacy/search/query/QueryGoal.java
index 455955da2..a9d0b06ab 100644
--- a/source/net/yacy/search/query/QueryGoal.java
+++ b/source/net/yacy/search/query/QueryGoal.java
@@ -52,7 +52,7 @@ public class QueryGoal {
private static char space = ' ';
private static char sq = '\'';
private static char dq = '"';
- private static String seps = ".:;#'*`,!$%()=?^<>/&_";
+ private static String seps = ".:;#*`,!$%()=?^<>/&_";
public String query_original;
private HandleSet include_hashes, exclude_hashes;
diff --git a/test/net/yacy/search/query/QueryGoalTest.java b/test/net/yacy/search/query/QueryGoalTest.java
new file mode 100644
index 000000000..74387082c
--- /dev/null
+++ b/test/net/yacy/search/query/QueryGoalTest.java
@@ -0,0 +1,38 @@
+package net.yacy.search.query;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class QueryGoalTest {
+
+ /**
+ * Test of getIncludeString method, of class QueryGoal.
+ */
+ @Test
+ public void testGetIncludeString() {
+ HashMap<String, String[]> testdata = new HashMap<String, String[]>();
+ // Prameter: (Query, [result_term1, result_term2 ..])
+ testdata.put("O'Reily's book", new String[]{"o'reily's", "book"});
+ testdata.put("\"O'Reily's book\"", new String[]{"o'reily's book"}); // quoted term
+ testdata.put("\"O'Reily's\" +book", new String[]{"o'reily's", "book"}); // +word
+ testdata.put("Umphrey's + McGee", new String[]{"umphrey's", "mcgee"});
+ testdata.put("'The Book' library", new String[]{"the book","library"}); //single quoted term
+
+ for (String testquery : testdata.keySet()) {
+ QueryGoal qg = new QueryGoal(testquery); // get test query
+ String[] singlestr = testdata.get(testquery); // get result strings
+
+ Iterator<String> it = qg.getIncludeStrings();
+ int i = 0;
+ while (it.hasNext()) {
+ String s = it.next();
+ System.out.println(singlestr[i] + " = " + s);
+ assertEquals(s, singlestr[i]);
+ i++;
+ }
+ }
+ }
+
+}