From 52d47a581d5abc20080c3aea4357f4775c1409ce Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Wed, 24 Oct 2018 11:52:57 +0200 Subject: [PATCH] fixed issue #438 --- .../engine/lucene/LuceneSearchService.java | 18 ++++++++++-------- src/site/markdown/engine/luceneservice.md | 11 +++++++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/lucene/LuceneSearchService.java b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/lucene/LuceneSearchService.java index 95bc6440b..9f68b01a9 100644 --- a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/lucene/LuceneSearchService.java +++ b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/lucene/LuceneSearchService.java @@ -218,9 +218,10 @@ public List search(String sSearchTerm, int pageSize, int pageInd parser.setAllowLeadingWildcard(true); // set default operator? - if (defaultOperator != null) + if (defaultOperator != null) { parser.setDefaultOperator(defaultOperator); - + } + long lsearchtime = System.currentTimeMillis(); TopDocs topDocs = null; TopDocsCollector collector = null; @@ -244,7 +245,7 @@ public List search(String sSearchTerm, int pageSize, int pageInd // sorted by sortoder logger.finest("......lucene result sorted by sortOrder= '" + sortOrder + "' "); // MAX_SEARCH_RESULT is limiting the total number of hits - collector = TopFieldCollector.create(sortOrder, maxSearchResult, false, false, false); + collector = TopFieldCollector.create(sortOrder, maxSearchResult, false, false, false, false); } else { // sorted by score @@ -386,12 +387,7 @@ public int getTotalHits(String sSearchTerm, int maxResult, Operator defaultOpera * extended with a users roles to test the read access level of each workitem * matching the search term. * - * The optional param 'defaultOperator' can be set to Operator.AND - * * @param sSearchTerm - * @param defaultOperator - * - optional to change the default search operator - * * @return extended search term * @throws QueryException * in case the searchtem is not understandable. @@ -504,6 +500,12 @@ QueryParser createQueryParser(Properties prop) { logger.finest("......DefaultOperator: AND"); parser.setDefaultOperator(Operator.AND); } + + // set setSplitOnWhitespace (issue #438) + String splitOnWhitespace = prop.getProperty("lucene.splitOnWhitespace","true"); + boolean bSplitOnWhitespace=Boolean.parseBoolean(splitOnWhitespace); + logger.finest("......SplitOnWhitespace: "+bSplitOnWhitespace); + parser.setSplitOnWhitespace(bSplitOnWhitespace); return parser; } diff --git a/src/site/markdown/engine/luceneservice.md b/src/site/markdown/engine/luceneservice.md index ab8e7c435..e282bc9b4 100644 --- a/src/site/markdown/engine/luceneservice.md +++ b/src/site/markdown/engine/luceneservice.md @@ -33,7 +33,9 @@ The custom configuration of the _LuceneService_ can be provided in the file _imi # Fields to be added into the searchindex lucence.fulltextFieldList=txtsearchstring,txtSubject,txtname,txtEmail,txtWorkflowAbstract,txtWorkflowSummary lucence.indexFieldListAnalyze= - lucence.indexFieldListNoAnalyze=datDate,txtWorkflowGroup,txtemail, datdate, datfrom, datto, numsequencenumber, txtUsername, + lucence.indexFieldListNoAnalyze=datDate,txtWorkflowGroup,txtemail, datdate, datfrom, datto, numsequencenumber, txtUsername + lucene.defaultOperator=AND + lucene.splitOnWhitespace=true ### IndexDir @@ -50,8 +52,13 @@ The property 'lucene.indexFieldListAnalyze' defines a comma separated list of fi ### IndexFieldListNoAnalyze The property 'lucene.indexFieldListNoAnalyze' defines a comma separated list of fields which will be added as keyword fields into the lucene index. The content of this fields will not be analyzed. So a exact phrase search is possible here. +### defaultOperator +The defaultOperator sets the boolean operator of the QueryParser. In default mode (AND\_OPERATOR) terms without any modifiers are considered optional: for example _capital of France_ is equal to _capital AND of AND France_. +In OR\_OPERATOR mode terms are considered to be in conjunction: the above mentioned query is parsed as _capital OR of OR France_ + +### splitOnWhitespace +Whether query text should be split on whitespace prior to analysis. Default is true. For example _cat dog_ will be treated as _cat AND dog_ - ## How to Initialize the Lucene Index The lucene index is automatically written into the Index Directory by the Imixs-Workflow engine.