mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
Make _all field accessible with GET
GET only returned null even when stored if requested with GET like this: `curl -XGET "http://localhost:9200/test/test/1?fields=_all"` Instead, it should simply behave like a String field and return the concatenated fields as String. closes #6924
This commit is contained in:
parent
08f8731b6f
commit
734e656a91
@ -56,7 +56,7 @@ import static org.elasticsearch.index.mapper.core.TypeParsers.parseField;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AllFieldMapper extends AbstractFieldMapper<Void> implements InternalMapper, RootMapper {
|
public class AllFieldMapper extends AbstractFieldMapper<String> implements InternalMapper, RootMapper {
|
||||||
|
|
||||||
public interface IncludeInAll extends Mapper {
|
public interface IncludeInAll extends Mapper {
|
||||||
|
|
||||||
@ -237,15 +237,13 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||||||
}
|
}
|
||||||
return analyzer;
|
return analyzer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void value(Object value) {
|
public String value(Object value) {
|
||||||
return null;
|
if (value == null) {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
@Override
|
return value.toString();
|
||||||
public Object valueForSearch(Object value) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -885,4 +885,28 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
|
|||||||
assertThat(getResponse.getField(field).getValues().get(1).toString(), equalTo("value2"));
|
assertThat(getResponse.getField(field).getValues().get(1).toString(), equalTo("value2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGet_allField() throws Exception {
|
||||||
|
prepareCreate("my-index")
|
||||||
|
.addMapping("my-type1", jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.startObject("my-type1")
|
||||||
|
.startObject("_all")
|
||||||
|
.field("store", true)
|
||||||
|
.endObject()
|
||||||
|
.startObject("properties")
|
||||||
|
.startObject("some_field")
|
||||||
|
.field("type", "string")
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject())
|
||||||
|
.get();
|
||||||
|
index("my-index", "my-type1", "1", "some_field", "some text");
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
GetResponse getResponse = client().prepareGet("my-index", "my-type1", "1").setFields("_all").get();
|
||||||
|
assertNotNull(getResponse.getField("_all").getValue());
|
||||||
|
assertThat(getResponse.getField("_all").getValue().toString(), equalTo("some text" + " "));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user