Skip to content

Commit

Permalink
Update TermExpander.java
Browse files Browse the repository at this point in the history
Fixed logic so "Nuix" type fuzzy resolution honors your choice of "content" and/or "properties" as terms source
  • Loading branch information
JuicyDragon committed May 14, 2019
1 parent 324011e commit 9f4fe22
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Java/src/main/java/com/nuix/superutilities/misc/TermExpander.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public List<ExpandedTermInfo> expandTerm(Case nuixCase, boolean content, boolean
}
} else if(FuzzyTermInfo.isFuzzyTerm(term)) {
if(fuzzyResolutionAlgorithm == SimilarityCalculation.Nuix) {
expandFuzzyWithNuix(nuixCase, term, scopeQuery, result);
expandFuzzyWithNuix(nuixCase, content, properties, term, scopeQuery, result);
} else {
expandFuzzyWithSimilarityFiltering(term, result, allTermStats);
}
Expand Down Expand Up @@ -221,15 +221,25 @@ private void expandFuzzyWithSimilarityFiltering(String term, List<ExpandedTermIn
* @param result Collection to add results to
* @throws IOException
*/
private void expandFuzzyWithNuix(Case nuixCase, String term, String scopeQuery, List<ExpandedTermInfo> result)
private void expandFuzzyWithNuix(Case nuixCase, boolean content, boolean properties, String term, String scopeQuery, List<ExpandedTermInfo> result)
throws IOException {
// Were going to ask Nuix what terms it gets for the fuzzy search
int currentProgress = 0;

// Build out the query we will be submitting to Nuix, including scope query only
// if it is not an empty string.
List<String> queryPieces = new ArrayList<String>();
queryPieces.add(term);
String termQueryPiece = "";
if(content && properties) {
termQueryPiece = String.format("content:%s OR properties:%s", term, term);
} else if(content && !properties) {
termQueryPiece = String.format("content:%s", term);
} else if(properties && !content) {
termQueryPiece = String.format("properties:%s", term);
} else if(!content && !properties) {
return;
}
queryPieces.add(termQueryPiece);
if(!scopeQuery.isEmpty()) { queryPieces.add(scopeQuery); }
String query = QueryHelper.parenThenJoinByAnd(queryPieces);

Expand All @@ -240,7 +250,7 @@ private void expandFuzzyWithNuix(Case nuixCase, String term, String scopeQuery,
currentProgress++;
fireProgressUpdated(currentProgress, items.size());
ExtendedItem eItem = (ExtendedItem)item;
for(String itemTerm : eItem.getTerms(term)) {
for(String itemTerm : eItem.getTerms(termQueryPiece)) {
distinctTerms.add(itemTerm);
}
}
Expand Down

0 comments on commit 9f4fe22

Please sign in to comment.