OSDN Git Service

Correct a problem where searching on an attribute without specifying a word search...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / REnSearch.java
index 5230b3c..059548e 100644 (file)
@@ -689,6 +689,9 @@ public class REnSearch {
                logger.log(logger.EXTREME, "Inside EnSearch.matchWords()");\r
                boolean subSelect = false;\r
                \r
+               NoteTable noteTable = new NoteTable(logger, conn);  \r
+               List<String> validGuids = new ArrayList<String>();\r
+               \r
                if (searchWords.size() > 0) \r
                        subSelect = true;\r
 \r
@@ -732,16 +735,14 @@ public class REnSearch {
                                        deleteQuery.exec("Delete from SEARCH_RESULTS_MERGE");\r
                                }\r
                        }\r
-               }\r
-               \r
-               NoteTable noteTable = new NoteTable(logger, conn);  \r
-               List<String> validGuids = new ArrayList<String>();\r
-               query.prepare("Select distinct guid from Note where guid in (Select guid from SEARCH_RESULTS)");\r
-               if (!query.exec()) \r
-                       logger.log(logger.LOW, "Error merging search results:" + query.lastError());\r
+\r
+                       query.prepare("Select distinct guid from Note where guid in (Select guid from SEARCH_RESULTS)");\r
+                       if (!query.exec()) \r
+                               logger.log(logger.LOW, "Error merging search results:" + query.lastError());\r
                \r
-               while (query.next()) {\r
-                       validGuids.add(query.valueString(0));\r
+                       while (query.next()) {\r
+                               validGuids.add(query.valueString(0));\r
+                       }\r
                }\r
                \r
                List<Note> noteIndex = noteTable.getAllNotes();\r
@@ -750,7 +751,7 @@ public class REnSearch {
                        Note n = noteIndex.get(i);\r
                        boolean good = true;\r
                        \r
-                       if (!validGuids.contains(n.getGuid()))\r
+                       if (!validGuids.contains(n.getGuid()) && subSelect)\r
                                good = false;\r
                                                \r
                        // Start matching special stuff, like tags & notebooks\r