Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
issue #438
  • Loading branch information
rsoika committed Oct 24, 2018
1 parent 4ba287c commit 52d47a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,10 @@ public List<ItemCollection> 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;
Expand All @@ -244,7 +245,7 @@ public List<ItemCollection> 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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 9 additions & 2 deletions src/site/markdown/engine/luceneservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 52d47a5

Please sign in to comment.