OSDN Git Service

Correct missing wildcard logic.
authorRandy Baumgarte <randy@fbn.cx>
Thu, 17 Feb 2011 21:09:33 +0000 (16:09 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Thu, 24 Feb 2011 01:00:45 +0000 (20:00 -0500)
src/cx/fbn/nevernote/sql/REnSearch.java

index 059548e..6079515 100644 (file)
@@ -710,14 +710,20 @@ public class REnSearch {
                NSqlQuery mergeQuery = new NSqlQuery(conn.getConnection());\r
                NSqlQuery deleteQuery = new NSqlQuery(conn.getConnection());\r
                \r
-               indexQuery.prepare("Select distinct guid from words where weight >= " +minimumRecognitionWeight +\r
-               " and word=:word");\r
                insertQuery.prepare("Insert into SEARCH_RESULTS (guid) values (:guid)");\r
                mergeQuery.prepare("Insert into SEARCH_RESULTS_MERGE (guid) values (:guid)");\r
                \r
                if (subSelect) {\r
                        for (int i=0; i<getWords().size(); i++) {\r
-                               indexQuery.bindValue(":word", getWords().get(i));\r
+                               if (getWords().get(i).indexOf("*") == 0) {\r
+                                       indexQuery.prepare("Select distinct guid from words where weight >= " +minimumRecognitionWeight +\r
+                                                       " and word=:word");\r
+                                       indexQuery.bindValue(":word", getWords().get(i));\r
+                               } else {\r
+                                       indexQuery.prepare("Select distinct guid from words where weight >= " +minimumRecognitionWeight +\r
+                                               " and word like :word");\r
+                                       indexQuery.bindValue(":word", getWords().get(i).replace("*", "%"));\r
+                               }\r
                                indexQuery.exec();\r
                                String guid = null;\r
                                while(indexQuery.next()) {\r