From: Randy Baumgarte Date: Mon, 23 Jan 2012 12:47:51 +0000 (-0500) Subject: Reworked search logic to better handle multiple positive/negative matching of the... X-Git-Tag: version0.1.1~77 X-Git-Url: http://git.sourceforge.jp/view?p=neighbornote%2FNeighborNote.git;a=commitdiff_plain;h=4651fb5d9db7bf494788aab4299c026bb18d65cf Reworked search logic to better handle multiple positive/negative matching of the same subset. --- diff --git a/src/cx/fbn/nevernote/sql/REnSearch.java b/src/cx/fbn/nevernote/sql/REnSearch.java index c6802e6..cec989a 100644 --- a/src/cx/fbn/nevernote/sql/REnSearch.java +++ b/src/cx/fbn/nevernote/sql/REnSearch.java @@ -129,19 +129,14 @@ public class REnSearch { if (tagNames.size() == 0 && !negative) return false; - if (tagNames.size() == 0 && negative) - return true; - boolean good = false; - for (int i=0; i=0) { - if (!negative) - returnPhrase = true; - } - if (text.indexOf(phrase)<0 && negative) - returnPhrase = true; + if (text.indexOf(phrase)>=0 && negative) { + return false; + } + if (text.indexOf(phrase) < 0 && !negative) + return false; } @@ -555,14 +533,13 @@ public class REnSearch { if (value.startsWith("-")) desiredState = !desiredState; int pos = n.getContent().indexOf(" -1 && value.startsWith("-") && (value.endsWith("*") || value.endsWith(":"))) return false; - if (pos == -1) + if (pos == -1 && !value.startsWith("-")) return false; - if (value.endsWith("*")) - returnTodo = true; + boolean returnTodo = false; while (pos > -1) { int endPos = n.getContent().indexOf("/>", pos); String segment = n.getContent().substring(pos, endPos); @@ -571,11 +548,15 @@ public class REnSearch { currentState = false; else currentState = true; - if (desiredState == currentState) + if (desiredState == currentState) + returnTodo = true; + if (value.endsWith("*") || value.endsWith(":")) returnTodo = true; pos = n.getContent().indexOf("