0

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();

3 Answers 3

1

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)
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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();

1 Comment

@user3549576 have you been able to try this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.