Skip to content

Commit

Permalink
(index) Fix bug related to debug print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
vlofgren committed Jul 22, 2023
1 parent ac2d703 commit cb55c76
Showing 1 changed file with 12 additions and 6 deletions.
Expand Up @@ -50,20 +50,20 @@ public SearchIndexSearchTerms getSearchTerms(SearchSubquery request) {
}

// we don't care if we can't find these:
addEachTerm(excludes, request.searchTermsExclude);
addEachTerm(priority, request.searchTermsPriority);
addEachNonMandatoryTerm(excludes, request.searchTermsExclude);
addEachNonMandatoryTerm(priority, request.searchTermsPriority);

return new SearchIndexSearchTerms(includes, excludes, priority, coherences);
}

private boolean addEachTerm(IntList ret, List<String> words) {
boolean success = true;

for (var exclude : words) {
var word = lookUpWord(exclude);
for (var word : words) {
var termId = lookUpWord(word);

if (word.isPresent()) {
lookUpWord(exclude).ifPresent(ret::add);
if (termId.isPresent()) {
lookUpWord(word).ifPresent(ret::add);
}
else {
success = false;
Expand All @@ -72,6 +72,12 @@ private boolean addEachTerm(IntList ret, List<String> words) {
return success;
}

private void addEachNonMandatoryTerm(IntList ret, List<String> words) {
for (var word : words) {
ret.add(lexicon.get(word));
}
}


public OptionalInt lookUpWord(String s) {
int ret = lexicon.get(s);
Expand Down

0 comments on commit cb55c76

Please sign in to comment.