ElasticSearch测试数据

curl命令数据

curl -XPUT http://127.0.0.1:9200/us/user/1 -d "{"email":"john@smith.com","name":"John Smith","username":"@john"}"


curl -XPUT http://127.0.0.1:9200/gb/user/2 -d "{"email" : "mary@jones.com","name" : "Mary Jones","username" : "@mary"}"


curl -XPUT http://127.0.0.1:9200/gb/tweet/3 -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://127.0.0.1:9200/us/tweet/4 -d "{"date" : "2014-09-14","name" : "John Smith","tweet" : "@mary it is not just text, it does everything","user_id" : 1}"


curl -XPUT http://127.0.0.1:9200/gb/tweet/5 -d "{"date" : "2014-09-15","name" : "Mary Jones","tweet" : "However did I manage before Elasticsearch?","user_id" : 2}"


curl -XPUT http://127.0.0.1:9200/us/tweet/6 -d "{"date" : "2014-09-16","name" : "John Smith","tweet" : "The Elasticsearch API is really easy to use","user_id" : 1}"


curl -XPUT http://127.0.0.1:9200/gb/tweet/7 -d "{"date" : "2014-09-17", "name" : "Mary Jones","tweet" : "The Query DSL is really powerful and flexible","user_id" : 2}"


curl -XPUT http://127.0.0.1:9200/us/tweet/8 -d "{"date" : "2014-09-18","name" : "John Smith","user_id" : 1}"


curl -XPUT http://127.0.0.1:9200/gb/tweet/9 -d "{"date" : "2014-09-19","name" : "Mary Jones","tweet" : "Geo-location aggregations are really cool","user_id" : 2}"


curl -XPUT http://127.0.0.1:9200/us/tweet/10 -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://127.0.0.1:9200/gb/tweet/11 -d "{"date" : "2014-09-21","name" : "Mary Jones","tweet" : "Elasticsearch is built for the cloud, easy to scale","user_id" : 2}"


curl -XPUT http://127.0.0.1:9200/us/tweet/12 -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://127.0.0.1:9200/gb/tweet/13 -d "{"date" : "2014-09-23","name" : "Mary Jones","tweet" : "So yes, I am an Elasticsearch fanboy","user_id" : 2}"


curl -XPUT http://127.0.0.1:9200/us/tweet/14 -d "{"date" : "2014-09-24","name" : "John Smith","tweet" : "How many more cheesy tweets do I have to write?","user_id" : 1}"

批量操作数据

POST /_bulk
{ "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 }
原文地址:https://www.cnblogs.com/shaosks/p/7515184.html