Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public static boolean exists(IndexSearcher searcher, Query query) throws IOExcep
return false;
}

private static TotalHits readTotalHits(StreamInput in) throws IOException {
public static TotalHits readTotalHits(StreamInput in) throws IOException {
long totalHits = in.readVLong();
TotalHits.Relation totalHitsRelation = TotalHits.Relation.EQUAL_TO;
if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0)) {
Expand Down Expand Up @@ -418,7 +418,7 @@ public static ScoreDoc readScoreDoc(StreamInput in) throws IOException {

private static final Class<?> GEO_DISTANCE_SORT_TYPE_CLASS = LatLonDocValuesField.newDistanceSort("some_geo_field", 0, 0).getClass();

private static void writeTotalHits(StreamOutput out, TotalHits totalHits) throws IOException {
public static void writeTotalHits(StreamOutput out, TotalHits totalHits) throws IOException {
out.writeVLong(totalHits.value);
if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0)) {
out.writeEnum(totalHits.relation);
Expand Down
18 changes: 3 additions & 15 deletions server/src/main/java/org/elasticsearch/search/SearchHits.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

import org.apache.lucene.search.TotalHits;
import org.apache.lucene.search.TotalHits.Relation;
import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
Expand Down Expand Up @@ -276,14 +276,7 @@ private static class Total implements Writeable, ToXContentFragment {
final TotalHits in;

Total(StreamInput in) throws IOException {
final long value = in.readVLong();
final Relation relation;
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
relation = in.readEnum(Relation.class);
} else {
relation = Relation.EQUAL_TO;
}
this.in = new TotalHits(value, relation);
this.in = Lucene.readTotalHits(in);
}

Total(TotalHits in) {
Expand All @@ -306,12 +299,7 @@ public int hashCode() {

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(in.value);
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
out.writeEnum(in.relation);
} else {
assert in.relation == Relation.EQUAL_TO;
}
Lucene.writeTotalHits(out, in);
}

@Override
Expand Down