(index) Fix bug related to debug print statements

This commit is contained in:
Viktor Lofgren 2023-07-22 14:20:52 +02:00
parent ac2d7034db
commit cb55c76664

View File

@ -50,8 +50,8 @@ public class SearchTermsService {
} }
// we don't care if we can't find these: // we don't care if we can't find these:
addEachTerm(excludes, request.searchTermsExclude); addEachNonMandatoryTerm(excludes, request.searchTermsExclude);
addEachTerm(priority, request.searchTermsPriority); addEachNonMandatoryTerm(priority, request.searchTermsPriority);
return new SearchIndexSearchTerms(includes, excludes, priority, coherences); return new SearchIndexSearchTerms(includes, excludes, priority, coherences);
} }
@ -59,11 +59,11 @@ public class SearchTermsService {
private boolean addEachTerm(IntList ret, List<String> words) { private boolean addEachTerm(IntList ret, List<String> words) {
boolean success = true; boolean success = true;
for (var exclude : words) { for (var word : words) {
var word = lookUpWord(exclude); var termId = lookUpWord(word);
if (word.isPresent()) { if (termId.isPresent()) {
lookUpWord(exclude).ifPresent(ret::add); lookUpWord(word).ifPresent(ret::add);
} }
else { else {
success = false; success = false;
@ -72,6 +72,12 @@ public class SearchTermsService {
return success; return success;
} }
private void addEachNonMandatoryTerm(IntList ret, List<String> words) {
for (var word : words) {
ret.add(lexicon.get(word));
}
}
public OptionalInt lookUpWord(String s) { public OptionalInt lookUpWord(String s) {
int ret = lexicon.get(s); int ret = lexicon.get(s);