From 4b9fcdb9000f7f42b9ff841f142d7a540d466c68 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Fri, 4 Jan 2013 23:55:34 +0100 Subject: [PATCH] noramalize the value even when getting it from source we need to in order to properly handle bytes, and normalize Integer to Long for example for consistency, the fact that mappers now handle different Objtes help here --- .../java/org/elasticsearch/index/get/ShardGetService.java | 4 ++++ .../elasticsearch/test/integration/get/GetActionTests.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/index/get/ShardGetService.java b/src/main/java/org/elasticsearch/index/get/ShardGetService.java index 2d13fbf7409..cb8e7350793 100644 --- a/src/main/java/org/elasticsearch/index/get/ShardGetService.java +++ b/src/main/java/org/elasticsearch/index/get/ShardGetService.java @@ -325,6 +325,10 @@ public class ShardGetService extends AbstractIndexShardComponent { searchLookup.setNextDocId(docIdAndVersion.docId); } value = searchLookup.source().extractValue(field); + // normalize the data if needed (mainly for binary fields, to convert from base64 strings to bytes) + if (value != null) { + value = x.mapper().valueForSearch(value); + } } } diff --git a/src/test/java/org/elasticsearch/test/integration/get/GetActionTests.java b/src/test/java/org/elasticsearch/test/integration/get/GetActionTests.java index 8cc67cfb1f6..04a173752ff 100644 --- a/src/test/java/org/elasticsearch/test/integration/get/GetActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/get/GetActionTests.java @@ -271,7 +271,7 @@ public class GetActionTests extends AbstractNodesTests { getResponse = client.prepareGet("test", "type1", "1").setFields("str", "int", "date").execute().actionGet(); assertThat(getResponse.exists(), equalTo(true)); assertThat((String) getResponse.field("str").getValue(), equalTo("test")); - assertThat((Integer) getResponse.field("int").getValue(), equalTo(42)); + assertThat((Long) getResponse.field("int").getValue(), equalTo(42l)); assertThat((String) getResponse.field("date").getValue(), equalTo("2012-11-13T15:26:14.000Z")); logger.info("--> non realtime get (from stored fields)");