Author: hansbak
Date: Mon Nov 7 12:04:16 2011
New Revision: 1198709
URL:
http://svn.apache.org/viewvc?rev=1198709&view=revLog:
create a configurable maxlength keyword for content search keywords
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentKeywordIndex.java
ofbiz/trunk/framework/common/config/keywordsearch.properties
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentKeywordIndex.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentKeywordIndex.java?rev=1198709&r1=1198708&r2=1198709&view=diff==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentKeywordIndex.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentKeywordIndex.java Mon Nov 7 12:04:16 2011
@@ -198,9 +198,12 @@ public class ContentKeywordIndex {
}
List<GenericValue> toBeStored = FastList.newInstance();
+ int keywordMaxLength = Integer.parseInt(UtilProperties.getPropertyValue("keywordsearch", "keyword.max.length"));
for (Map.Entry<String, Long> entry: keywords.entrySet()) {
- GenericValue contentKeyword = delegator.makeValue("ContentKeyword", UtilMisc.toMap("contentId", content.getString("contentId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue()));
- toBeStored.add(contentKeyword);
+ if (entry.getKey().length() <= keywordMaxLength) {
+ GenericValue contentKeyword = delegator.makeValue("ContentKeyword", UtilMisc.toMap("contentId", content.getString("contentId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue()));
+ toBeStored.add(contentKeyword);
+ }
}
if (toBeStored.size() > 0) {
if (Debug.verboseOn()) Debug.logVerbose("[ContentKeywordIndex.indexKeywords] Storing " + toBeStored.size() + " keywords for contentId " + content.getString("contentId"), module);
Modified: ofbiz/trunk/framework/common/config/keywordsearch.properties
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/keywordsearch.properties?rev=1198709&r1=1198708&r2=1198709&view=diff==============================================================================
--- ofbiz/trunk/framework/common/config/keywordsearch.properties (original)
+++ ofbiz/trunk/framework/common/config/keywordsearch.properties Mon Nov 7 12:04:16 2011
@@ -34,3 +34,6 @@ stem.bag=:s:ies:y:
# Characters that should be used as token separators when pulling out keywords
index.keyword.separators=;: ,.!?\t\"\'\r\n\\/()[]{}*%<>-+_
+
+# The keyword will not create when word's length more than keyword.max.length
+keyword.max.length = 15