Merge pull request #2475 from millmanorama/2140

2140 Update artifact generation for Regex queries with overlapping chunks
This commit is contained in:
Richard Cordovano 2017-01-23 12:27:29 -05:00 committed by GitHub
commit 92616368f0

View File

@ -162,9 +162,9 @@ final class RegexQuery implements KeywordSearchQuery {
// Set the fields we want to have returned by the query.
if (KeywordSearchSettings.getShowSnippets()) {
solrQuery.setFields(Server.Schema.CONTENT_STR.toString(), Server.Schema.ID.toString());
solrQuery.setFields(Server.Schema.CONTENT_STR.toString(), Server.Schema.ID.toString(), Server.Schema.CHUNK_SIZE.toString());
} else {
solrQuery.setFields(Server.Schema.ID.toString());
solrQuery.setFields(Server.Schema.ID.toString(), Server.Schema.CHUNK_SIZE.toString());
}
filters.stream()
.map(KeywordQueryFilter::toString)
@ -217,6 +217,7 @@ final class RegexQuery implements KeywordSearchQuery {
List<KeywordHit> hits = new ArrayList<>();
final String docId = solrDoc.getFieldValue(Server.Schema.ID.toString()).toString();
final Integer chunkSize = (Integer) solrDoc.getFieldValue(Server.Schema.CHUNK_SIZE.toString());
String content = solrDoc.getOrDefault(Server.Schema.CONTENT_STR.toString(), "").toString(); //NON-NLS
@ -241,6 +242,11 @@ final class RegexQuery implements KeywordSearchQuery {
while (hitMatcher.find(offset)) {
StringBuilder snippet = new StringBuilder();
if (hitMatcher.start() >= chunkSize) {
break;
}
String hit = hitMatcher.group();
// Back the matcher offset up by 1 character as it will have eaten