Skip to content

Commit

Permalink
Update ESQueryResult.java
Browse files Browse the repository at this point in the history
fix variants counting
  • Loading branch information
RDBloese authored Jul 6, 2023
1 parent 8825c21 commit 6d356e8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/tla/backend/es/query/ESQueryResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.Iterator;
import java.util.Set;
import java.util.HashSet;

import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
Expand Down Expand Up @@ -88,16 +90,19 @@ public void addAggregationResults(Map<String, Map<String, Long>> aggs) {
* return total number of results.
*/
public long getHitCount() {
int i = 0;
Set<String> idSet = new HashSet<>();
int index;
Iterator<SearchHit<T>> iterator = hits.iterator();
while (iterator.hasNext()) {
SearchHit searchHit = (SearchHit) iterator.next();
String source = searchHit.getId();
if (!source.contains("-") || source.contains("-00")) {
i++;
index = source.indexOf("-");
if (index != -1) {
source = source.substring(0, index);
}
idSet.add(source);
}
return (long) i;
return (long) idSet.size();
}

/**
Expand Down

0 comments on commit 6d356e8

Please sign in to comment.