diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java index 585c4b410e987cebb088a30d92afb1a39e343d1d..1e887dc8a131c1e52ef39c242b22453b2d5e6b78 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilder.java @@ -50,14 +50,14 @@ public class LuceneQueryBuilder // query adaptation // - // In wildcard mode field separator character needs to be escaped to disable field query. - // In basic mode wildcard characters in the query need to be escaped too. - private static final char[] CHARS_ESCAPED_IN_WILCARD_MODE = { FIELD_SEPARATOR }; - private static final char[] CHARS_ESCAPED_IN_BASIC_MODE = - { FIELD_SEPARATOR, '*', '?' }; + // For now both wildcard and basic modes escape the same characters. If we decide + // to escape wildcard characters in basic mode unescape the following code. + // private static final char[] CHARS_ESCAPED_IN_BASIC_MODE = + // { FIELD_SEPARATOR, '*', '?' }; + private static final char[] CHARS_ESCAPED_IN_BASIC_MODE = CHARS_ESCAPED_IN_WILCARD_MODE; public static String adaptQuery(String userQuery, boolean useWildcardSearchMode) { @@ -95,7 +95,7 @@ public class LuceneQueryBuilder } return sb.toString(); } - + // /** diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilderTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilderTest.java index b8bdf95f5006ad1f05a7ba71214c880db5659b4f..ad218283384f160c67b08b9d4bd5f19e6c1563c1 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilderTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/LuceneQueryBuilderTest.java @@ -34,8 +34,7 @@ public class LuceneQueryBuilderTest extends AssertJUnit return new Object[][] { { "abc", "*abc*" }, - { "code:CP registrator:Joe", "*code\\:CP registrator\\:Joe*" }, - { "a*b?c:", "*a\\*b\\?c\\:*" }, }; + { "code:CP registrator:Joe", "*code\\:CP registrator\\:Joe*" } }; } @DataProvider(name = "wildcardModeQueries") @@ -44,8 +43,7 @@ public class LuceneQueryBuilderTest extends AssertJUnit return new Object[][] { { "abc", "abc" }, - { "code:CP registrator:Joe", "code\\:CP registrator\\:Joe" }, - { "a*b?c:", "a*b?c\\:" }, }; + { "code:CP registrator:Joe", "code\\:CP registrator\\:Joe" } }; } @Test(dataProvider = "basicModeQueries")