OSDN Git Service

uni-gramで日本語全文検索できるように変更。ノートコンテンツとタイトルが対象。日本語全文検索時に日本語がハイライトされない問題を修正。
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / REnSearch.java
index 1a0ec5b..4ee21b7 100644 (file)
@@ -380,6 +380,7 @@ public class REnSearch {
        private void parseTerms(List<String> words) {\r
                for (int i=0; i<words.size(); i++) {\r
                        String word = words.get(i);\r
+                       System.out.println("word = " + word);\r
                        int pos = word.indexOf(":");\r
                        if (word.startsWith("any:")) {\r
                                any = true;\r
@@ -702,28 +703,33 @@ public class REnSearch {
                }\r
 \r
                NSqlQuery insertQuery = new NSqlQuery(conn.getConnection());\r
-               NSqlQuery indexQuery = new NSqlQuery(conn.getIndexConnection());\r
+//             NSqlQuery indexQuery = new NSqlQuery(conn.getIndexConnection());\r
                NSqlQuery mergeQuery = new NSqlQuery(conn.getConnection());\r
                NSqlQuery deleteQuery = new NSqlQuery(conn.getConnection());\r
+               NSqlQuery ftlQuery = new NSqlQuery(conn.getConnection());\r
+               ftlQuery.prepare("SELECT N.GUID AS GUID FROM FTL_SEARCH_DATA(:text, 0, 0) FT, NOTE N WHERE FT.TABLE='NOTE' AND N.GUID=FT.KEYS[0]");\r
                \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
-                               if (getWords().get(i).indexOf("*") == -1) {\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
+//                             if (getWords().get(i).indexOf("*") == -1) {\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
+                               \r
+                               ftlQuery.bindValue(":text", getWords().get(i));\r
+                               ftlQuery.exec();\r
+                               \r
                                String guid = null;\r
-                               while(indexQuery.next()) {\r
-                                       guid = indexQuery.valueString(0);\r
+                               while(ftlQuery.next()) {\r
+                                       guid = ftlQuery.valueString(0);\r
                                        if (i==0 || any) {\r
                                                insertQuery.bindValue(":guid", guid);\r
                                                insertQuery.exec();\r