I want to get JSON with curl command, so with below command I am getting output:
curl -GET http://localhost:9200/oldindex/_mapping?pretty
{
"gl-events_1" : {
"mappings" : {
"message" : {
"dynamic" : "false",
"dynamic_templates" : [
{
"fields" : {
"path_match" : "fields.*",
"mapping" : {
"doc_values" : true,
"index" : true,
"type" : "keyword"
}
}
}
],
"properties" : {
"alert" : {
"type" : "boolean"
},
"event_definition_id" : {
"type" : "keyword"
},
"event_definition_type" : {
"type" : "keyword"
},
"fields" : {
"type" : "object",
"dynamic" : "true"
},
"id" : {
"type" : "keyword"
},
"key" : {
"type" : "keyword"
},
"key_tuple" : {
"type" : "keyword"
},
"message" : {
"type" : "text",
"norms" : false,
"fields" : {
"keyword" : {
"type" : "keyword"
}
},
"analyzer" : "standard"
},
"origin_context" : {
"type" : "keyword"
},
"priority" : {
"type" : "long"
},
"source" : {
"type" : "keyword"
},
"source_streams" : {
"type" : "keyword"
},
"streams" : {
"type" : "keyword"
},
"timerange_end" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss.SSS"
},
"timerange_start" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss.SSS"
},
"timestamp" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss.SSS"
},
"timestamp_processing" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss.SSS"
},
"triggered_jobs" : {
"type" : "keyword"
}
}
}
}
}
}
Now i want to store this output as json file so I copied it in file and gave extension as
.json
But when i try to put with curl I am getting below error
curl -X PUT http://localhost:9200/new_good -H 'Content-Type: application/json' -d sampl.json
{"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}
But when i run below command with same json format directly it works,
curl -X PUT \
http://localhost:9200/new_good \
-H 'Content-Type: application/json' \
-d '{"mappings" : {
"message" : {
"dynamic_templates" : [
{
"internal_fields" : {
"match" : "gl2_*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "keyword"
}
}
},
{
"store_generic" : {
"match_mapping_type" : "string",
"mapping" : {
"type" : "keyword"
}
}
}
],
"properties" : {
"LoggerName" : {
"type" : "keyword"
},
"MessageParam0" : {
"type" : "keyword"
},
"MessageParam1" : {
"type" : "long"
},
"MessageParam2" : {
"type" : "keyword"
},
"MessageParam3" : {
"type" : "keyword"
},
"MessageParam4" : {
"type" : "keyword"
},
"MessageParam5" : {
"type" : "keyword"
},
"MessageParam6" : {
"type" : "keyword"
},
"MessageParam7" : {
"type" : "keyword"
},
"MessageParam8" : {
"type" : "keyword"
},
"Severity" : {
"type" : "keyword"
},
"SourceClassName" : {
"type" : "keyword"
},
"SourceMethodName" : {
"type" : "keyword"
},
"SourceSimpleClassName" : {
"type" : "keyword"
},
"StackTrace" : {
"type" : "keyword"
},
"Thread" : {
"type" : "keyword"
},
"Time" : {
"type" : "keyword"
},
"facility" : {
"type" : "keyword"
},
"full_message" : {
"type" : "text",
"analyzer" : "standard"
},
"gl2_accounted_message_size" : {
"type" : "long"
},
"gl2_message_id" : {
"type" : "keyword"
},
"gl2_processing_timestamp" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss.SSS"
},
"gl2_receive_timestamp" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss.SSS"
},
"gl2_remote_ip" : {
"type" : "keyword"
},
"gl2_remote_port" : {
"type" : "long"
},
"gl2_source_input" : {
"type" : "keyword"
},
"gl2_source_node" : {
"type" : "keyword"
},
"level" : {
"type" : "long"
},
"message" : {
"type" : "text",
"analyzer" : "standard"
},
"source" : {
"type" : "text",
"analyzer" : "analyzer_keyword",
"fielddata" : true
},
"streams" : {
"type" : "keyword"
},
"timestamp" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss.SSS"
}
}
}
}
}
}'
What I want is store curl GET command output as valid json which I can use in curl PUT,
curl get > some.json
curl put -d some.json
I am new to this and i tried several options with jq as well but that also didn't workd for me.
Please guide me here.
Regards
SAM
Asked by Samurai
(95 rep)
Jun 1, 2022, 06:23 AM
Last activity: Jun 4, 2025, 12:03 PM
Last activity: Jun 4, 2025, 12:03 PM