Human readable representation of total hits count

This commit is contained in:
Andrea Cavalli 2021-08-04 01:16:17 +02:00
parent 9734d78839
commit 9d326f5a8b
2 changed files with 10 additions and 0 deletions

View File

@ -197,6 +197,7 @@ versions:
onlyTopScores: boolean
computeScores: boolean
TotalHitsCount:
stringRepresenter: "it.cavallium.dbengine.lucene.LuceneUtils.toHumanReadableString"
data:
value: long
exact: boolean

View File

@ -478,4 +478,13 @@ public class LuceneUtils {
totalHitsCount.exact() && totalHitsCount1.exact()
);
}
@SuppressWarnings("unused")
public static String toHumanReadableString(TotalHitsCount totalHitsCount) {
if (totalHitsCount.exact()) {
return Long.toString(totalHitsCount.value());
} else {
return totalHitsCount.value() + "+";
}
}
}