curl -XPUT 'http://localhost:9200/us/user/1?pretty=1' -d ' | |
{ | |
"email" : "john@smith.com", | |
"name" : "John Smith", | |
"username" : "@john" | |
} | |
' | |
curl -XPUT 'http://localhost:9200/gb/user/2?pretty=1' -d ' | |
{ | |
"email" : "mary@jones.com", | |
"name" : "Mary Jones", | |
"username" : "@mary" | |
} | |
' | |
curl -XPUT 'http://localhost:9200/gb/tweet/3?pretty=1' -d ' | |
{ | |
"date" : "2014-09-13", | |
"name" : "Mary Jones", | |
"tweet" : "Elasticsearch means full text search has never been so easy", | |
"user_id" : 2 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/us/tweet/4?pretty=1' -d ' | |
{ | |
"date" : "2014-09-14", | |
"name" : "John Smith", | |
"tweet" : "@mary it is not just text, it does everything", | |
"user_id" : 1 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/gb/tweet/5?pretty=1' -d ' | |
{ | |
"date" : "2014-09-15", | |
"name" : "Mary Jones", | |
"tweet" : "However did I manage before Elasticsearch?", | |
"user_id" : 2 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/us/tweet/6?pretty=1' -d ' | |
{ | |
"date" : "2014-09-16", | |
"name" : "John Smith", | |
"tweet" : "The Elasticsearch API is really easy to use", | |
"user_id" : 1 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/gb/tweet/7?pretty=1' -d ' | |
{ | |
"date" : "2014-09-17", | |
"name" : "Mary Jones", | |
"tweet" : "The Query DSL is really powerful and flexible", | |
"user_id" : 2 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/us/tweet/8?pretty=1' -d ' | |
{ | |
"date" : "2014-09-18", | |
"name" : "John Smith", | |
"user_id" : 1 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/gb/tweet/9?pretty=1' -d ' | |
{ | |
"date" : "2014-09-19", | |
"name" : "Mary Jones", | |
"tweet" : "Geo-location aggregations are really cool", | |
"user_id" : 2 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/us/tweet/10?pretty=1' -d ' | |
{ | |
"date" : "2014-09-20", | |
"name" : "John Smith", | |
"tweet" : "Elasticsearch surely is one of the hottest new NoSQL products", | |
"user_id" : 1 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/gb/tweet/11?pretty=1' -d ' | |
{ | |
"date" : "2014-09-21", | |
"name" : "Mary Jones", | |
"tweet" : "Elasticsearch is built for the cloud, easy to scale", | |
"user_id" : 2 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/us/tweet/12?pretty=1' -d ' | |
{ | |
"date" : "2014-09-22", | |
"name" : "John Smith", | |
"tweet" : "Elasticsearch and I have left the honeymoon stage, and I still love her.", | |
"user_id" : 1 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/gb/tweet/13?pretty=1' -d ' | |
{ | |
"date" : "2014-09-23", | |
"name" : "Mary Jones", | |
"tweet" : "So yes, I am an Elasticsearch fanboy", | |
"user_id" : 2 | |
} | |
' | |
curl -XPUT 'http://localhost:9200/us/tweet/14?pretty=1' -d ' | |
{ | |
"date" : "2014-09-24", | |
"name" : "John Smith", | |
"tweet" : "How many more cheesy tweets do I have to write?", | |
"user_id" : 1 | |
} | |
' |
This comment has been minimized.
This comment has been minimized.
Assuming that you don't already have the
|
This comment has been minimized.
This comment has been minimized.
A bulk update with the data above and curl would look like this:
Note that curl's |
This comment has been minimized.
This comment has been minimized.
@alanktwong That's the awesome version. |
This comment has been minimized.
This comment has been minimized.
Alternatively, if you’re in the online version of this book, you can click here to open in Sense. |
This comment has been minimized.
This comment has been minimized.
Link in the last comment above is dead too |
This comment has been minimized.
This comment has been minimized.
Yes, @santanu-dey: that was exactly @cwhsu1984's point. Lol |
This comment has been minimized.
This comment has been minimized.
this worked for me: curl -XPOST 'http://localhost:9200/_bulk?pretty' -d '
{ "create": { "_index": "us", "_type": "user", "_id": "1" }}
{ "email" : "john@smith.com", "name" : "John Smith", "username" : "@john" }
{ "create": { "_index": "gb", "_type": "user", "_id": "2" }}
{ "email" : "mary@jones.com", "name" : "Mary Jones", "username" : "@mary" }
{ "create": { "_index": "gb", "_type": "tweet", "_id": "3" }}
{ "date" : "2014-09-13", "name" : "Mary Jones", "tweet" : "Elasticsearch means full text search has never been so easy", "user_id" : 2 }
{ "create": { "_index": "us", "_type": "tweet", "_id": "4" }}
{ "date" : "2014-09-14", "name" : "John Smith", "tweet" : "@mary it is not just text, it does everything", "user_id" : 1 }
{ "create": { "_index": "gb", "_type": "tweet", "_id": "5" }}
{ "date" : "2014-09-15", "name" : "Mary Jones", "tweet" : "However did I manage before Elasticsearch?", "user_id" : 2 }
{ "create": { "_index": "us", "_type": "tweet", "_id": "6" }}
{ "date" : "2014-09-16", "name" : "John Smith", "tweet" : "The Elasticsearch API is really easy to use", "user_id" : 1 }
{ "create": { "_index": "gb", "_type": "tweet", "_id": "7" }}
{ "date" : "2014-09-17", "name" : "Mary Jones", "tweet" : "The Query DSL is really powerful and flexible", "user_id" : 2 }
{ "create": { "_index": "us", "_type": "tweet", "_id": "8" }}
{ "date" : "2014-09-18", "name" : "John Smith", "user_id" : 1 }
{ "create": { "_index": "gb", "_type": "tweet", "_id": "9" }}
{ "date" : "2014-09-19", "name" : "Mary Jones", "tweet" : "Geo-location aggregations are really cool", "user_id" : 2 }
{ "create": { "_index": "us", "_type": "tweet", "_id": "10" }}
{ "date" : "2014-09-20", "name" : "John Smith", "tweet" : "Elasticsearch surely is one of the hottest new NoSQL products", "user_id" : 1 }
{ "create": { "_index": "gb", "_type": "tweet", "_id": "11" }}
{ "date" : "2014-09-21", "name" : "Mary Jones", "tweet" : "Elasticsearch is built for the cloud, easy to scale", "user_id" : 2 }
{ "create": { "_index": "us", "_type": "tweet", "_id": "12" }}
{ "date" : "2014-09-22", "name" : "John Smith", "tweet" : "Elasticsearch and I have left the honeymoon stage, and I still love her.", "user_id" : 1 }
{ "create": { "_index": "gb", "_type": "tweet", "_id": "13" }}
{ "date" : "2014-09-23", "name" : "Mary Jones", "tweet" : "So yes, I am an Elasticsearch fanboy", "user_id" : 2 }
{ "create": { "_index": "us", "_type": "tweet", "_id": "14" }}
{ "date" : "2014-09-24", "name" : "John Smith", "tweet" : "How many more cheesy tweets do I have to write?", "user_id" : 1 }' |
This comment has been minimized.
This comment has been minimized.
@clintongormley |
This comment has been minimized.
This comment has been minimized.
@ZacharyRSmith nice |
This comment has been minimized.
This comment has been minimized.
goood |
This comment has been minimized.
This comment has been minimized.
good job ! |
This comment has been minimized.
This comment has been minimized.
I got that: |
This comment has been minimized.
This comment has been minimized.
mapping type has been removed in Es 6.x . See:https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html |
This comment has been minimized.
This comment has been minimized.
for ES6.x, I use the follow
|
This comment has been minimized.
This comment has been minimized.
Since change in change in elasticsearch request for strict content-type checking , make sure to add header
|
This comment has been minimized.
This comment has been minimized.
do add header -H 'Content-Type: application/json', then how to do with quote> |
This comment has been minimized.
This comment has been minimized.
Elastic 6.x allows only one Type in Index, and version 7.x will completely remove Type. |
This comment has been minimized.
This comment has been minimized.
Rejecting mapping update to [gb] as the final mapping would have more than 1 type: [tweet, user] |
This comment has been minimized.
This comment has been minimized.
add header
reference:Bulk Api |
This comment has been minimized.
This comment has been minimized.
in es6.x, this is useful
|
This comment has been minimized.
This comment has been minimized.
@zhengfeng-zhu |
This comment has been minimized.
This comment has been minimized.
In Elasticsearch 7.x the type was deprecated, so this bulk will be like this? POST /_bulk
{"create":{"_index":"us","_id":"1"}}
{"email":"john@smith.com","name":"John Smith","username":"@john"}
{"create":{"_index":"gb","_id":"2"}}
{"email":"mary@jones.com","name":"Mary Jones","username":"@mary"}
{"create":{"_index":"gb","_id":"3"}}
{"date":"2014-09-13","name":"Mary Jones","tweet":"Elasticsearch means full text search has never been so easy","user_id":2}
{"create":{"_index":"us","_id":"4"}}
{"date":"2014-09-14","name":"John Smith","tweet":"@mary it is not just text, it does everything","user_id":1}
{"create":{"_index":"gb","_id":"5"}}
{"date":"2014-09-15","name":"Mary Jones","tweet":"However did I manage before Elasticsearch?","user_id":2}
{"create":{"_index":"us","_id":"6"}}
{"date":"2014-09-16","name":"John Smith","tweet":"The Elasticsearch API is really easy to use","user_id":1}
{"create":{"_index":"gb","_id":"7"}}
{"date":"2014-09-17","name":"Mary Jones","tweet":"The Query DSL is really powerful and flexible","user_id":2}
{"create":{"_index":"us","_id":"8"}}
{"date":"2014-09-18","name":"John Smith","user_id":1}
{"create":{"_index":"gb","_id":"9"}}
{"date":"2014-09-19","name":"Mary Jones","tweet":"Geo-location aggregations are really cool","user_id":2}
{"create":{"_index":"us","_id":"10"}}
{"date":"2014-09-20","name":"John Smith","tweet":"Elasticsearch surely is one of the hottest new NoSQL products","user_id":1}
{"create":{"_index":"gb","_id":"11"}}
{"date":"2014-09-21","name":"Mary Jones","tweet":"Elasticsearch is built for the cloud, easy to scale","user_id":2}
{"create":{"_index":"us","_id":"12"}}
{"date":"2014-09-22","name":"John Smith","tweet":"Elasticsearch and I have left the honeymoon stage, and I still love her.","user_id":1}
{"create":{"_index":"gb","_id":"13"}}
{"date":"2014-09-23","name":"Mary Jones","tweet":"So yes, I am an Elasticsearch fanboy","user_id":2}
{"create":{"_index":"us","_id":"14"}}
{"date":"2014-09-24","name":"John Smith","tweet":"How many more cheesy tweets do I have to write?","user_id":1} |
This comment has been minimized.
This comment has been minimized.
@alvesgabriel, I think you are now mixing up tweet and user. Following the advince of elastic, by default you split up different types in different indexes, so gb-user, gb-tweet, us-user, us-tweet, which results in:
|
This comment has been minimized.
This comment has been minimized.
Ok @maarten-kieft, I understood now. |
This comment has been minimized.
This comment has been minimized.
@zhenfeng-zhu |
This comment has been minimized.
This comment has been minimized.
This is very easy to use |
This comment has been minimized.
This comment has been minimized.
It's cool,i remove type can run it...Maybe i need read document again |
This comment has been minimized.
This comment has been minimized.
@maarten-kieft Comment has the best example for 7.x, copy paste in Kibana console works fine. |
This comment has been minimized.
This comment has been minimized.
es returns error
since 7.x ,one these shells are @deprecated |
This comment has been minimized.
This comment has been minimized.
@maarten-kieft, thanks ! |
This comment has been minimized.
This comment has been minimized.
@maarten-kieft thanks a lot for the example. Helped me a ton! |
This comment has been minimized.
I think that host may be parametrized, it will be very applicable.