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
This commit is contained in:
Shay Banon 2013-01-04 23:55:34 +01:00
parent fe38cecabd
commit 4b9fcdb900
2 changed files with 5 additions and 1 deletions

View File

@ -325,6 +325,10 @@ public class ShardGetService extends AbstractIndexShardComponent {
searchLookup.setNextDocId(docIdAndVersion.docId); searchLookup.setNextDocId(docIdAndVersion.docId);
} }
value = searchLookup.source().extractValue(field); 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);
}
} }
} }

View File

@ -271,7 +271,7 @@ public class GetActionTests extends AbstractNodesTests {
getResponse = client.prepareGet("test", "type1", "1").setFields("str", "int", "date").execute().actionGet(); getResponse = client.prepareGet("test", "type1", "1").setFields("str", "int", "date").execute().actionGet();
assertThat(getResponse.exists(), equalTo(true)); assertThat(getResponse.exists(), equalTo(true));
assertThat((String) getResponse.field("str").getValue(), equalTo("test")); 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")); assertThat((String) getResponse.field("date").getValue(), equalTo("2012-11-13T15:26:14.000Z"));
logger.info("--> non realtime get (from stored fields)"); logger.info("--> non realtime get (from stored fields)");