From 4319e3cb057227b39beca64291c27714405c884e Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 7 Feb 2011 20:24:15 +0200 Subject: [PATCH] add a test to fetch just an array element (which has no mapping) --- .../search/scriptfield/ScriptFieldSearchTests.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java index f794e6eeecd..32cbfcb38e1 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java @@ -145,6 +145,7 @@ public class ScriptFieldSearchTests extends AbstractNodesTests { .setSource(jsonBuilder().startObject() .startObject("obj1").field("test", "something").endObject() .startObject("obj2").startArray("arr2").value("arr_value1").value("arr_value2").endArray().endObject() + .startArray("arr3").startObject().field("arr3_field1", "arr3_value1").endObject().endArray() .endObject()) .execute().actionGet(); client.admin().indices().refresh(refreshRequest()).actionGet(); @@ -156,6 +157,7 @@ public class ScriptFieldSearchTests extends AbstractNodesTests { .addScriptField("s_obj1_test", "_source.obj1.test") .addScriptField("s_obj2", "_source.obj2") .addScriptField("s_obj2_arr2", "_source.obj2.arr2") + .addScriptField("s_arr3", "_source.arr3") .execute().actionGet(); Map sObj1 = (Map) response.hits().getAt(0).field("_source.obj1").value(); @@ -176,5 +178,8 @@ public class ScriptFieldSearchTests extends AbstractNodesTests { assertThat(sObj2Arr2.size(), equalTo(2)); assertThat(sObj2Arr2.get(0).toString(), equalTo("arr_value1")); assertThat(sObj2Arr2.get(1).toString(), equalTo("arr_value2")); + + List sObj2Arr3 = (List) response.hits().getAt(0).field("s_arr3").value(); + assertThat(((Map) sObj2Arr3.get(0)).get("arr3_field1").toString(), equalTo("arr3_value1")); } } \ No newline at end of file