OSDN Git Service

ノートコンテンツをwordテーブルに登録しないように変更。
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / REnSearch.java
index bafb04b..9dccbd6 100644 (file)
@@ -33,7 +33,6 @@ import com.evernote.edam.type.Note;
 import com.evernote.edam.type.Notebook;\r
 import com.evernote.edam.type.Tag;\r
 \r
-import cx.fbn.nevernote.Global;\r
 import cx.fbn.nevernote.sql.driver.NSqlQuery;\r
 import cx.fbn.nevernote.utilities.ApplicationLogger;\r
 \r
@@ -392,16 +391,16 @@ public class REnSearch {
                                searchPhrases.add(word.toLowerCase());\r
                        }\r
                        if (!searchPhrase && pos < 0) {\r
-                               if (word != null && word.length() > 0 && !Global.automaticWildcardSearches())\r
+                               if (word != null && word.length() > 0/* && !Global.automaticWildcardSearches()*/)\r
                                        getWords().add(word); \r
-                               if (word != null && word.length() > 0 && Global.automaticWildcardSearches()) {\r
-                                       String wildcardWord = word;\r
-                                       if (!wildcardWord.startsWith("*"))\r
-                                               wildcardWord = "*"+wildcardWord;\r
-                                       if (!wildcardWord.endsWith("*"))\r
-                                               wildcardWord = wildcardWord+"*";\r
-                                       getWords().add(wildcardWord); \r
-                               }\r
+//                             if (word != null && word.length() > 0 && Global.automaticWildcardSearches()) {\r
+//                                     String wildcardWord = word;\r
+//                                     if (!wildcardWord.startsWith("*"))\r
+//                                             wildcardWord = "*"+wildcardWord;\r
+//                                     if (!wildcardWord.endsWith("*"))\r
+//                                             wildcardWord = wildcardWord+"*";\r
+//                                     getWords().add(wildcardWord); \r
+//                             }\r
 //                             getWords().add("*"+word+"*");           //// WILDCARD\r
                        }\r
                        if (word.startsWith("intitle:")) \r
@@ -702,7 +701,7 @@ 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
@@ -713,20 +712,32 @@ public class REnSearch {
                \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
+                               // wordsテーブルから検索\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
+                               String guid = null;\r
+                               while(indexQuery.next()) {\r
+                                       guid = indexQuery.valueString(0);\r
+                                       if (i==0 || any) {\r
+                                               insertQuery.bindValue(":guid", guid);\r
+                                               insertQuery.exec();\r
+                                       } else {\r
+                                               mergeQuery.bindValue(":guid", guid);\r
+                                               mergeQuery.exec();\r
+                                       }\r
+                               }\r
                                \r
+                               // luceneによる全文検索\r
                                ftlQuery.bindValue(":text", getWords().get(i));\r
                                ftlQuery.exec();\r
-                               \r
-                               String guid = null;\r
                                while(ftlQuery.next()) {\r
                                        guid = ftlQuery.valueString(0);\r
                                        if (i==0 || any) {\r
@@ -737,6 +748,7 @@ public class REnSearch {
                                                mergeQuery.exec();\r
                                        }\r
                                }\r
+                               \r
                                if (i>0 && !any) {\r
                                        deleteQuery.exec("Delete from SEARCH_RESULTS where guid not in (select guid from SEARCH_RESULTS_MERGE)");\r
                                        deleteQuery.exec("Delete from SEARCH_RESULTS_MERGE");\r