Found Same Error

Continuing the discussion from "not_x_content_exception" while trying to PUT simple file with column mappings into ES via cURL:

with cURL - curl -X PUT "localhost:9200/test?pretty" -H "Content-Type: application/json" -d'{"settings" : {"number_of_shards" : 1}, "mappings" : { "_doc" : { "properties" : {"field1" : {"type" : "text" }}}}}"

Please post the entire error response as well as the version you are using.
Please also format your code/logs/config using the </> button, or markdown style back ticks. It helps to make things easy to read which helps us help you :slight_smile:

1 Like

currently i'm using version 6.5.3 and i found error

C:\Users\Ms>curl -XPUT "localhost:9200/twitter?pretty" -H "Content-Type: application/json" -d '{"settings":{"index":{"number_of_shards":1,"number_of_replicas":2}}}'
{
"error" : {
"root_cause" : [
{
"type" : "not_x_content_exception",
"reason" : "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
}
],
"type" : "not_x_content_exception",
"reason" : "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
},
"status" : 500
}

I'm on version 6.5.3 too and have no problems running the same command:

user@es-dev:~$ curl -XPUT "localhost:9200/twitter?pretty" -H "Content-Type: application/json" -d '{"settings":{"index":{"number_of_shards":1,"number_of_replicas":2}}}'
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "twitter"
}
user@es-dev:~$ curl -XGET 'localhost:9200/twitter?pretty'
{
  "twitter" : {
    "aliases" : { },
    "mappings" : { },
    "settings" : {
      "index" : {
        "creation_date" : "1545206310178",
        "number_of_shards" : "1",
        "number_of_replicas" : "2",
        "uuid" : "8eS4IIUaRmWpg6YPOQroSA",
        "version" : {
          "created" : "6050399"
        },
        "provided_name" : "twitter"
      }
    }
  }
}

So the command should work.

Could there be something in the way you've configured or started your Elasticsearch cluster which stops you from creating indices? Could you try to create the index without specifying the settings? E.g. just run:

curl -XPUT 'localhost:9200/twitter'

If this works, it proves you can create indices within your cluster and so there must be something funny going on with the settings.

1 Like

Thank you sir when i run that command and its give proper output same as yours but when i'm going to adding mapping its give me error can you suggest code to add mapping?

Now that we know you can create indices in the cluster it's time to debug the rest of the command.

Since the entire command works for me I wonder if there is a hidden character in there, causing the trouble? To find out you should try to build up the command from scratch and test each iteration, for instance you could start by just specifying the primary shards (you can add the replicas later):

user@es-dev:~$ curl -XPUT 'localhost:9200/twitter' -H 'Content-Type: application/json' -d '{"settings":{"index":{"number_of_shards":1}}}'
{"acknowledged":true,"shards_acknowledged":true,"index":"twitter"}

If this works, then there is something strange with the replica settings.

If it doesn't work, well you can always just rely on the command that worked for creating indices but specify the number of primary and replica shards in a separate Index Template.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.