List of usage examples for org.apache.lucene.search SortField getMissingValue
public Object getMissingValue()
From source file:org.apache.solr.schema.AbstractEnumField.java
License:Apache License
@Override public SortField getSortField(SchemaField field, boolean top) { SortField result = getSortField(field, SortField.Type.INT, top, Integer.MIN_VALUE, Integer.MAX_VALUE); if (null == result.getMissingValue()) { // special case default behavior: assume missing values are "below" all enum values result.setMissingValue(Integer.MIN_VALUE); }//from w w w . j a v a 2s .c om return result; }
From source file:org.codelibs.elasticsearch.common.lucene.Lucene.java
License:Apache License
public static void writeTopDocs(StreamOutput out, TopDocs topDocs) throws IOException { if (topDocs instanceof TopFieldDocs) { out.writeBoolean(true);//w w w . java 2s.com TopFieldDocs topFieldDocs = (TopFieldDocs) topDocs; out.writeVInt(topDocs.totalHits); out.writeFloat(topDocs.getMaxScore()); out.writeVInt(topFieldDocs.fields.length); for (SortField sortField : topFieldDocs.fields) { if (sortField.getClass() == GEO_DISTANCE_SORT_TYPE_CLASS) { // for geo sorting, we replace the SortField with a SortField that assumes a double field. // this works since the SortField is only used for merging top docs SortField newSortField = new SortField(sortField.getField(), SortField.Type.DOUBLE); newSortField.setMissingValue(sortField.getMissingValue()); sortField = newSortField; } if (sortField.getClass() != SortField.class) { throw new IllegalArgumentException("Cannot serialize SortField impl [" + sortField + "]"); } if (sortField.getField() == null) { out.writeBoolean(false); } else { out.writeBoolean(true); out.writeString(sortField.getField()); } if (sortField.getComparatorSource() != null) { IndexFieldData.XFieldComparatorSource comparatorSource = (IndexFieldData.XFieldComparatorSource) sortField .getComparatorSource(); writeSortType(out, comparatorSource.reducedType()); writeMissingValue(out, comparatorSource.missingValue(sortField.getReverse())); } else { writeSortType(out, sortField.getType()); writeMissingValue(out, sortField.getMissingValue()); } out.writeBoolean(sortField.getReverse()); } out.writeVInt(topDocs.scoreDocs.length); for (ScoreDoc doc : topFieldDocs.scoreDocs) { writeFieldDoc(out, (FieldDoc) doc); } } else { out.writeBoolean(false); out.writeVInt(topDocs.totalHits); out.writeFloat(topDocs.getMaxScore()); out.writeVInt(topDocs.scoreDocs.length); for (ScoreDoc doc : topDocs.scoreDocs) { writeScoreDoc(out, doc); } } }