From 9a79fb40bf35c0264c2e9a0192133d43f9825562 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 6 Nov 2012 19:54:36 +0100 Subject: [PATCH] lucene 4: sort values on hit are Text, not BytesRef --- .../search/internal/InternalSearchHit.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java b/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java index adc97b9feaf..650240e1895 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java @@ -298,10 +298,11 @@ public class InternalSearchHit implements SearchHit { public void sortValues(Object[] sortValues) { // LUCENE 4 UPGRADE: There must be a better way + // we want to convert to a Text object here, and not BytesRef if (sortValues != null) { - for (int i=0; i 0) { matchedFilters = new String[size]; for (int i = 0; i < size; i++) { - matchedFilters[i] = in.readUTF(); + matchedFilters[i] = in.readString(); } } @@ -617,8 +617,8 @@ public class InternalSearchHit implements SearchHit { public void writeTo(StreamOutput out, InternalSearchHits.StreamContext context) throws IOException { out.writeFloat(score); - out.writeUTF(id); - out.writeUTF(type); + out.writeString(id); + out.writeString(type); out.writeLong(version); out.writeBytesReference(source); if (explanation == null) { @@ -655,7 +655,7 @@ public class InternalSearchHit implements SearchHit { Class type = sortValue.getClass(); if (type == String.class) { out.writeByte((byte) 1); - out.writeUTF((String) sortValue); + out.writeString((String) sortValue); } else if (type == Integer.class) { out.writeByte((byte) 2); out.writeInt((Integer) sortValue); @@ -677,9 +677,9 @@ public class InternalSearchHit implements SearchHit { } else if (type == Boolean.class) { out.writeByte((byte) 8); out.writeBoolean((Boolean) sortValue); - } else if (type == BytesRef.class) { + } else if (sortValue instanceof Text) { out.writeByte((byte) 9); - out.writeBytesRef((BytesRef) sortValue); + out.writeText((Text) sortValue); } else { throw new IOException("Can't handle sort field value of type [" + type + "]"); } @@ -692,7 +692,7 @@ public class InternalSearchHit implements SearchHit { } else { out.writeVInt(matchedFilters.length); for (String matchedFilter : matchedFilters) { - out.writeUTF(matchedFilter); + out.writeString(matchedFilter); } }