. Fix for AWC-589 (Error searching for "+ test")

- Fixed to ignore empty terms after stripping operators from search text

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2600 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-03-31 15:07:29 +00:00
parent 2ad12b2b1b
commit b29006fbca

View File

@@ -158,6 +158,8 @@ public final class SearchContext implements Serializable
text = text.substring(1); text = text.substring(1);
} }
if (text.length() != 0)
{
// prepend NOT operator if supplied // prepend NOT operator if supplied
if (operatorNOT) if (operatorNOT)
{ {
@@ -181,6 +183,7 @@ public final class SearchContext implements Serializable
nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeText).append(OP_WILDCARD); nameAttrBuf.append("@").append(nameAttr).append(":*").append(safeText).append(OP_WILDCARD);
} }
} }
}
else else
{ {
// multiple word search // multiple word search
@@ -198,6 +201,8 @@ public final class SearchContext implements Serializable
fullTextBuf.append('('); fullTextBuf.append('(');
nameAttrBuf.append('('); nameAttrBuf.append('(');
int termCount = 0;
int tokenCount = t.countTokens(); int tokenCount = t.countTokens();
for (int i=0; i<tokenCount; i++) for (int i=0; i<tokenCount; i++)
{ {
@@ -215,7 +220,7 @@ public final class SearchContext implements Serializable
if (term.length() != 0) if (term.length() != 0)
{ {
// operators such as AND and OR are only make sense for full text searching // operators such as AND and OR are only make sense for full text searching
if (i != 0 && !operatorAND) if (termCount != 0 && !operatorAND)
{ {
fullTextBuf.append("OR "); fullTextBuf.append("OR ");
nameAttrBuf.append("OR "); nameAttrBuf.append("OR ");
@@ -248,6 +253,8 @@ public final class SearchContext implements Serializable
} }
fullTextBuf.append(' '); fullTextBuf.append(' ');
nameAttrBuf.append(' '); nameAttrBuf.append(' ');
termCount++;
} }
} }
fullTextBuf.append(')'); fullTextBuf.append(')');