Hit implements Writable, Comparable<Hit> { @Override public int compareTo(final Hit o) { int result = Float.compare(o._score, _score); if (result == 0) { if (_docId < o._docId) { result = -1; } else if (_docId > o._docId){ result = 1; } else { result = o._shard.compareTo(_shard); } } return result; } Hit();  Hit(final String shard, final String node, final float score, final int id);  Hit(final String shard, final String node, final float score, final int id, WritableType[] sortFieldTypes); String getShard(); String getNode(); float getScore(); int getDocId(); void setDocId(final int docId); void setSortFields(WritableComparable[] sortFields); WritableComparable[] getSortFields(); @Override void readFields(final DataInput in); @Override void write(final DataOutput out); @Override int compareTo(final Hit o); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }
@Test public void testCompareTo() { for (HitPair hitPair: HIT_PAIRS) { assertEquals(String.format("%s.compareTo(%s): %d", hitPair.hitA, hitPair.hitB, hitPair.compareValue), hitPair.compareValue, hitPair.hitA.compareTo(hitPair.hitB)); } }