Fixed matched terms
This commit is contained in:
parent
ef42633e05
commit
d0a1a4a8e7
@ -88,7 +88,7 @@ public class SearchService {
|
||||
QueryBuilder textPhraseQuery = QueryBuilders.matchPhraseQuery("sections.text", must.toLowerCase(Locale.ROOT))
|
||||
.queryName(must);
|
||||
QueryBuilder filenamePhraseQuery = QueryBuilders.matchPhraseQuery("filename", must.toLowerCase(Locale.ROOT))
|
||||
.queryName(must);
|
||||
.queryName("filename." + must);
|
||||
QueryBuilder filenameOrTextMustQuery = QueryBuilders.boolQuery()
|
||||
.should(textPhraseQuery)
|
||||
.should(filenamePhraseQuery);
|
||||
@ -99,7 +99,7 @@ public class SearchService {
|
||||
QueryBuilder textTermQuery = QueryBuilders.termQuery("sections.text", should.toLowerCase(Locale.ROOT))
|
||||
.queryName(should);
|
||||
QueryBuilder filenameTermQuery = QueryBuilders.termQuery("filename", should.toLowerCase(Locale.ROOT))
|
||||
.queryName(should);
|
||||
.queryName("filename." + should);
|
||||
entireQuery.should(textTermQuery);
|
||||
entireQuery.should(filenameTermQuery);
|
||||
sectionsQueries.should(textTermQuery);
|
||||
@ -139,7 +139,7 @@ public class SearchService {
|
||||
|
||||
private MatchedDocument convertSearchHit(SearchHit hit, Query query) {
|
||||
|
||||
Set<String> matchesTerms = Arrays.stream(hit.getMatchedQueries()).collect(Collectors.toSet());
|
||||
Set<String> matchesTerms = Arrays.stream(hit.getMatchedQueries()).map(match -> match.contains("filename.") ? match.replace("filename.", "") : match).collect(Collectors.toSet());
|
||||
Set<String> unmatchedTerms = Stream.concat(query.getMusts().stream(), query.getShoulds().stream())
|
||||
.filter(term -> !matchesTerms.contains(term))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user