Skip to content

Retrieving byte type stored field fails #1702

Closed
@marchh

Description

@marchh

If you write a single java.lang.Byte type via json, it can't be read back.

The following error occurs:
Failed to execute phase [query_fetch], total failure; shardFailures {RemoteTransportException[[Spot][inet[/192.168.0.124:9300]][search/phase/query+fetch]]; nested: IOException[Can't write type [class java.lang.Byte]]; }

The following code produces the error:

Index-Mapping (template)
...
"ct" : {
"type" : "byte",
"store" : "yes",
"index" : "no"
}

...

Writing the document:

XContentBuilder jsonB = jsonBuilder();
jsonB.startObject();
...
jsonB.field("ct", (byte)5);
jsonB.endObject();
...
es.getClient().prepareIndex(INDEX_DOCUMENTS, "document",uid).setSource(jsonB).execute().actionGet();


Reading back:

QueryBuilder b = QueryBuilders.queryString(str).defaultOperator(Operator.OR).allowLeadingWildcard(false).useDisMax(true);
SearchRequestBuilder request = es.getClient().prepareSearch(INDEX_DOCUMENTS)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.addFields("ct")
.setFrom(n).setSize(limit)
.setQuery(b);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions