Improve highlight query in case of a regex with dir tree / blackboard saved results, now it should not return chunks that do not have exact regex match

This commit is contained in:
adam-m 2012-05-17 15:04:24 -04:00
parent 752a22a7c9
commit 77d7570e48

View File

@ -135,9 +135,13 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup {
chunksQuery.escape();
}
*/
Keyword keywordQuery = new Keyword(this.keywordHitQuery, false);
String queryStr = KeywordSearchUtil.escapeLuceneQuery(this.keywordHitQuery, true, false);
if (isRegex) {
//use white-space sep. field to get exact matches only of regex query result
queryStr = Server.Schema.CONTENT_WS + ":" + "\"" + queryStr + "\"";
}
Keyword keywordQuery = new Keyword(queryStr, false);
chunksQuery = new LuceneQuery(keywordQuery);
chunksQuery.escape();
KeywordQueryFilter contentIdFilter = new KeywordQueryFilter(FilterType.CHUNK, contentId);
chunksQuery.setFilter(contentIdFilter);
try {