sort field can be null (when sorting on score for example), make sure we take it into account when serializing

This commit is contained in:
kimchy 2010-03-23 08:53:58 +02:00
parent 89043b113a
commit 14af9d28fd
1 changed files with 11 additions and 2 deletions

View File

@ -116,7 +116,11 @@ public class Lucene {
SortField[] fields = new SortField[in.readVInt()];
for (int i = 0; i < fields.length; i++) {
fields[i] = new SortField(in.readUTF(), in.readVInt(), in.readBoolean());
String field = null;
if (in.readBoolean()) {
field = in.readUTF();
}
fields[i] = new SortField(field, in.readVInt(), in.readBoolean());
}
FieldDoc[] fieldDocs = new FieldDoc[in.readVInt()];
@ -170,7 +174,12 @@ public class Lucene {
out.writeVInt(topFieldDocs.fields.length);
for (SortField sortField : topFieldDocs.fields) {
out.writeUTF(sortField.getField());
if (sortField.getField() == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
out.writeUTF(sortField.getField());
}
out.writeVInt(sortField.getType());
out.writeBoolean(sortField.getReverse());
}