Jeroen Hoffman pushed to branch bugfix/CMS-10098 at cms-community / 
hippo-addon-search-service


Commits:
dff6be5f by Jeroen Hoffman at 2016-06-06T14:50:23+02:00
CMS-10098: used SearchService.DEFAULT_WILDCARD_POSTFIX_LENGTH on two more 
occasions and removed the now useless FullTextSearchParser#getMinimalLength

- - - - -


2 changed files:

- jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/Filter.java
- 
jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/FullTextSearchParser.java


Changes:

=====================================
jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/Filter.java
=====================================
--- a/jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/Filter.java
+++ b/jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/Filter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2012-2016 Hippo B.V. (http://www.onehippo.com)
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,15 +25,17 @@ import javax.jcr.Session;
 
 import org.hippoecm.repository.util.DateTools;
 import org.onehippo.cms7.services.search.query.constraint.DateConstraint;
+import org.onehippo.cms7.services.search.service.SearchService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Filter {
 
     static final Logger log = LoggerFactory.getLogger(Filter.class);
+
     private static final String[] DEFAULT_SKIPS = new String[]{"."};
 
-    private  int wildcardPostfixMinLength = 5;
+    private  int wildcardPostfixMinLength = 
SearchService.DEFAULT_WILDCARD_POSTFIX_LENGTH;
 
     private StringBuilder jcrExpressionBuilder;
 
@@ -93,7 +95,7 @@ public class Filter {
                 return;
             }
         } else {
-            String parsedText = 
FullTextSearchParser.fullTextParseCmsSimpleSearchMode(fullTextSearch, false, 
wildcardPostfixMinLength);
+            String parsedText = 
FullTextSearchParser.fullTextParseCmsSimpleSearchMode(fullTextSearch, false);
 
             if (fulltextWildcardPostfixed && fullTextSearch.length() > 
wildcardPostfixMinLength) {
                 String parsedTextWildCardPostFixed = 
FullTextSearchParser.fullTextParseCmsSimpleSearchMode(fullTextSearch, true, 
wildcardPostfixMinLength);


=====================================
jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/FullTextSearchParser.java
=====================================
--- 
a/jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/FullTextSearchParser.java
+++ 
b/jcr/src/main/java/org/onehippo/cms7/services/search/jcr/query/FullTextSearchParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2012-2016 Hippo B.V. (http://www.onehippo.com)
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.onehippo.cms7.services.search.jcr.query;
 import java.util.StringTokenizer;
 
 import org.apache.commons.lang.StringUtils;
+import org.onehippo.cms7.services.search.service.SearchService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,8 +36,6 @@ public final class FullTextSearchParser {
 
     private final static String ignoredChars = DEFAULT_IGNORED_CHARS;
 
-    private final static int minimalLength = 3;
-
     private static final String WHITESPACE_PATTERN = "\\s+";
 
     private FullTextSearchParser() {
@@ -64,8 +63,9 @@ public final class FullTextSearchParser {
 
 
     public static String fullTextParseCmsSimpleSearchMode(String value, final 
boolean wildcardPostfix) {
-        return fullTextParseCmsSimpleSearchMode(value, wildcardPostfix, 
getMinimalLength());
+        return fullTextParseCmsSimpleSearchMode(value, wildcardPostfix, 
SearchService.DEFAULT_WILDCARD_POSTFIX_LENGTH);
     }
+
     public static String fullTextParseCmsSimpleSearchMode(String value, final 
boolean wildcardPostfix, final int minimalLength) {
 
         value = foldToASCIIReplacer(value.trim());
@@ -115,7 +115,7 @@ public final class FullTextSearchParser {
 
 
             if (wildcardPostfix && tb.length() < minimalLength && 
!isOperatorToken) {
-                // for wildcard postfixing we demand the term to be at least 
as long as #getMinimalLength()
+                // for wildcard postfixing we demand the term to be at least 
as long as minimal length
                 continue;
             }
 
@@ -157,11 +157,6 @@ public final class FullTextSearchParser {
         return whereClauseBuilder.toString();
     }
 
-    public static int getMinimalLength() {
-        return minimalLength;
-    }
-
-
     /**
      * <p>
      * Removes invalid chars, escapes some chars. If 
<code>allowSingleNonLeadingWildCard</code> is <code>true</code>, there



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-search-service/commit/dff6be5f41ae23aa8391a78f36dee5d8db6b02ff
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to