Merge pull request #7 from Alfresco/fix-search-556

Implement fix to handle negation edge case
This commit is contained in:
Michael
2017-11-30 16:55:23 +00:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

View File

@@ -346,7 +346,7 @@ public class FTSQueryParser
}
constraints.add(constraint);
}
if (constraints.size() == 1)
if (constraints.size() == 1 && Occur.EXCLUDE != constraints.get(0).getOccur())
{
return constraints.get(0);
}

View File

@@ -180,6 +180,7 @@ ftsTest:
"*woof*woof*" ->"(TERM *woof*woof*)"
"cm:content.mimetype:*" -> "(TERM * (FIELD_REF content.mimetype (PREFIX cm)))"
ftsTermOrPhrase:
"name:woof" -> "(TERM woof (FIELD_REF name))"
"cm_name:woof" -> "(TERM woof (FIELD_REF cm_name))"
@@ -223,7 +224,9 @@ ftsFieldGroupTest:
"[12 TO 14]" -> "(FG_RANGE INCLUSIVE 12 14 INCLUSIVE)"
"<12 TO 14>" -> "(FG_RANGE EXCLUSIVE 12 14 EXCLUSIVE)"
"(apple cheese and (pear or banana or not orange))" -> "(FIELD_DISJUNCTION (FIELD_CONJUNCTION (FIELD_DEFAULT (FG_TERM apple)) (FIELD_DEFAULT (FG_TERM cheese)) (FIELD_DEFAULT (FIELD_DISJUNCTION (FIELD_CONJUNCTION (FIELD_DEFAULT (FG_TERM pear))) (FIELD_CONJUNCTION (FIELD_DEFAULT (FG_TERM banana))) (FIELD_CONJUNCTION (FIELD_NEGATION (FG_TERM orange)))))))"
"(apple chesse and banana)" -> (FIELD_DISJUNCTION (FIELD_CONJUNCTION (FIELD_DEFAULT (FG_TERM apple)) (FIELD_DEFAULT (FG_TERM chesse)) (FIELD_DEFAULT (FG_TERM banana))))
"(apple chesse and not banana)" -> (FIELD_DISJUNCTION (FIELD_CONJUNCTION (FIELD_DEFAULT (FG_TERM apple)) (FIELD_DEFAULT (FG_TERM chesse)) (FIELD_NEGATION (FG_TERM banana))))
"(apple chesse and (not banana))" -> (FIELD_DISJUNCTION (FIELD_CONJUNCTION (FIELD_DEFAULT (FG_TERM apple)) (FIELD_DEFAULT (FG_TERM chesse)) (FIELD_DEFAULT (FIELD_DISJUNCTION (FIELD_CONJUNCTION (FIELD_NEGATION (FG_TERM banana)))))))
ftsFieldGroupTerm:
"woof" -> "woof"