Created
November 15, 2012 12:11
-
-
Save radu-gheorghe/4078353 to your computer and use it in GitHub Desktop.
Elasticsearch bulk insert with index name in URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat req | |
{ "index" : { "_type" : "type1", "_id" : "1" } } | |
{ "field1" : "value1" } | |
{ "index" : { "_type" : "type1", "_id" : "2" } } | |
{ "field1" : "value2" } | |
$ curl -XPOST localhost:9200/testing/_bulk?pretty=true --data-binary @req | |
{ | |
"took" : 5, | |
"items" : [ { | |
"index" : { | |
"_index" : "testing", | |
"_type" : "type1", | |
"_id" : "1", | |
"_version" : 2, | |
"ok" : true | |
} | |
}, { | |
"index" : { | |
"_index" : "testing", | |
"_type" : "type1", | |
"_id" : "2", | |
"_version" : 2, | |
"ok" : true | |
} | |
} ] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#note how the index in the file overrides the one in the URL | |
$ cat req | |
{ "index" : { "_index": "override", "_type" : "type1", "_id" : "1" } } | |
{ "field1" : "value1" } | |
{ "index" : { "_index": "override", "_type" : "type1", "_id" : "2" } } | |
{ "field1" : "value2" } | |
$ curl -XPOST localhost:9200/testing/_bulk?pretty=true --data-binary @req | |
{ | |
"took" : 234, | |
"items" : [ { | |
"index" : { | |
"_index" : "override", | |
"_type" : "type1", | |
"_id" : "1", | |
"_version" : 1, | |
"ok" : true | |
} | |
}, { | |
"index" : { | |
"_index" : "override", | |
"_type" : "type1", | |
"_id" : "2", | |
"_version" : 1, | |
"ok" : true | |
} | |
} ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment