Reputation: 307
I am getting this error while trying to set mapping..
Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes
XContentBuilder mapping = XContentFactory.jsonBuilder()
.startObject("mydocuments")
.startObject("mytype")
.startObject("properties")
.startObject("blob_field")
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject()
.endObject();
PutMappingResponse putMappingResponse = client.admin().indices()
.preparePutMapping("mydocuments")
.setType("mytype")
.setSource(mapping)
.execute().actionGet();
Upvotes: 0
Views: 2618
Reputation: 141
Could you print your request body and try it in command line? Try to print this:
client.admin().indices()
.preparePutMapping("mydocuments")
.setType("mytype")
.setSource(mapping)
Upvotes: 1
Reputation: 217514
You need to convert your mapping object to a string first
XContentBuilder mapping = XContentFactory.jsonBuilder()
.startObject("mydocuments")
.startObject("mytype")
.startObject("properties")
.startObject("blob_field")
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject()
.endObject();
PutMappingResponse putMappingResponse = client.admin().indices()
.preparePutMapping("mydocuments")
.setType("mytype")
.setSource(mapping.string()) <---- transform to string
.execute().actionGet();
Upvotes: 0
Reputation: 2294
Is this with Elasticsearch 2.0? In 2.0 they no longer shade dependencies. Add the required Jackson dependencies to your classpath and the error may be resolved.
Upvotes: 0