本文共 11641 字,大约阅读时间需要 38 分钟。
[looking@master ~]$ curl localhost:9200/_cat/indices?vhealth status index uuid pri rep docs.count docs.deleted store.size pri.store.sizeyellow open website svdjlzy2TfCQFLHcKWhjRw 1 1 2 0 8.9kb 8.9kbyellow open bank E-6sCm3iRRqSweO9L5nWow 1 1 1000 0 414.3kb 414.3kbyellow open megacorp rzaxRxNTRTyF3YsKlrjxxA 1 1 2 0 6.4kb 6.4kbyellow open blogs qfnun_91RI2O1lgTjnBmCQ 3 1 0 0 849b 849b
[looking@master ~]$ curl localhost:9200/megacorp/_mapping?pretty{ "megacorp" : { "mappings" : { "properties" : { "about" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "age" : { "type" : "long" }, "first_name" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "interests" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } }, "fielddata" : true }, "last_name" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "properties" : { "properties" : { "interests" : { "properties" : { "fielddata" : { "type" : "boolean" }, "type" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } } } } } } } } }}
[looking@master ~]$ curl localhost:9200/_alias?pretty{ "website" : { "aliases" : { } }, "bank" : { "aliases" : { "banks" : { } } }, "megacorp" : { "aliases" : { } }, "blogs" : { "aliases" : { } }}
[looking@master ~]$ curl -XGET localhost:9200/blogs/_alias/*?pretty{ "blogs" : { "aliases" : { "blogs_alias" : { } } }}
[looking@master ~]$ curl -XGET localhost:9200/*/_alias/blogs_alias?pretty{ "blogs" : { "aliases" : { "blogs_alias" : { } } }}
[looking@master ~]$ curl -XPOST 'localhost:9200/_aliases?pretty' -H 'Content-Type: application/json' -d '{ "actions": [ {"add": {"index": "bank", "alias": "banks"}} ]}'{ "acknowledged" : true}
[looking@master ~]$ curl -XPOST 'localhost:9200/_aliases?pretty' -H 'Content-Type: application/json' -d '> {> "actions": [> {"remove": {"index": "bank", "alias": "banks"}}> ]> }> '{ "acknowledged" : true}
[looking@master ~]$ curl localhost:9200/bank/_alias?pretty{ "bank" : { "aliases" : { "banks" : { } } }}[looking@master ~]$ curl -XPOST 'localhost:9200/_aliases?pretty' -H 'Content-Type: application/json' -d '> {> "actions": [> {"remove": {"index": "bank", "alias": "banks"}},> {"add": {"index": "bank", "alias": "bank_bak"}}> ]> }> '{ "acknowledged" : true}[looking@master ~]$ curl localhost:9200/bank/_alias?pretty{ "bank" : { "aliases" : { "bank_bak" : { } } }}
[looking@master ~]$ curl -XGET localhost:9200/megacorp/employee/_search?pretty{ "took" : 3, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 2, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_score" : 1.0, "_source" : { "first_name" : "Looking", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests" : [ "sports", "music" ] } }, { "_index" : "megacorp", "_type" : "employee", "_id" : "3", "_score" : 1.0, "_source" : { "first_name" : "Douglas", "last_name" : "Fir", "age" : 35, "about" : "I like to build cabinets", "interests" : [ "forestry" ] } } ] }}
[looking@master ~]$ curl -XDELETE localhost:9200/megacorp?pretty{ "acknowledged" : true}
[looking@master ~]$ curl -X GET "localhost:9200/_count?pretty"{ "count" : 1005, "_shards" : { "total" : 6, "successful" : 6, "skipped" : 0, "failed" : 0 }}
[looking@master ~]$ curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' -H 'Content-Type: application/json' --data-binary "@accounts.json" ... { "index" : { "_index" : "bank", "_type" : "account", "_id" : "990", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 998, "_primary_term" : 1, "status" : 201 } }, { "index" : { "_index" : "bank", "_type" : "account", "_id" : "995", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 999, "_primary_term" : 1, "status" : 201 } } ]}
[looking@master packages]$ curl -X PUT "localhost:9200/megacorp/employee/1?pretty" -H 'Content-Type: application/json' -d'> {> "first_name" : "John",> "last_name" : "Smith",> "age" : 25,> "about" : "I love to go rock climbing",> "interests": [ "sports", "music" ]> }> '{ "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 0, "_primary_term" : 1}[looking@master packages]$ curl -X PUT "localhost:9200/megacorp/employee/2?pretty" -H 'Content-Type: application/json' -d'> {> "first_name" : "Jane",> "last_name" : "Smith",> "age" : 32,> "about" : "I like to collect rock albums",> "interests": [ "music" ]> }> '[ "forestry" ]}'{ "_index" : "megacorp", "_type" : "employee", "_id" : "2", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 1, "_primary_term" : 1}[looking@master packages]$ curl -X PUT "localhost:9200/megacorp/employee/3?pretty" -H 'Content-Type: application/json' -d'> {> "first_name" : "Douglas",> "last_name" : "Fir",> "age" : 35,> "about": "I like to build cabinets",> "interests": [ "forestry" ]> }> '{ "_index" : "megacorp", "_type" : "employee", "_id" : "3", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 2, "_primary_term" : 1}
[looking@master packages]$ curl -X GET "localhost:9200/megacorp/employee/1?pretty"{ "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_version" : 1, "_seq_no" : 0, "_primary_term" : 1, "found" : true, "_source" : { "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests" : [ "sports", "music" ] }}
[looking@master ~]$ curl -XDELETE localhost:9200/megacorp/employee/2?pretty{ "_index" : "megacorp", "_type" : "employee", "_id" : "2", "_version" : 3, "result" : "deleted", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 7, "_primary_term" : 11}------------------------------------------------------------[looking@master ~]$ curl -XGET localhost:9200/megacorp/employee/_search?pretty{ "took" : 1241, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 2, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_score" : 1.0, "_source" : { "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests" : [ "sports", "music" ] } }, { "_index" : "megacorp", "_type" : "employee", "_id" : "3", "_score" : 1.0, "_source" : { "first_name" : "Douglas", "last_name" : "Fir", "age" : 35, "about" : "I like to build cabinets", "interests" : [ "forestry" ] } } ] }}
[looking@master ~]$ curl -XPOST 'localhost:9200/megacorp/employee/1/_update?pretty' -H 'Content-Type: application/json' -d '{"doc":{ "first_name": "Looking" }}'{ "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_version" : 4, "result" : "updated", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 8, "_primary_term" : 11}------------------------------------------------------------[looking@master ~]$ curl -XGET localhost:9200/megacorp/employee/_search?pretty { "took" : 18, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 2, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_score" : 1.0, "_source" : { "first_name" : "Looking", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests" : [ "sports", "music" ] } }, { "_index" : "megacorp", "_type" : "employee", "_id" : "3", "_score" : 1.0, "_source" : { "first_name" : "Douglas", "last_name" : "Fir", "age" : 35, "about" : "I like to build cabinets", "interests" : [ "forestry" ] } } ] }}
[looking@master packages]$ curl -X GET "localhost:9200/megacorp/employee/_search?q=last_name:Smith&pretty"{ "took" : 178, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 2, "relation" : "eq" }, "max_score" : 0.47000363, "hits" : [ { "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_score" : 0.47000363, "_source" : { "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests" : [ "sports", "music" ] } }, { "_index" : "megacorp", "_type" : "employee", "_id" : "2", "_score" : 0.47000363, "_source" : { "first_name" : "Jane", "last_name" : "Smith", "age" : 32, "about" : "I like to collect rock albums", "interests" : [ "music" ] } } ] }}
转载地址:http://hcjqi.baihongyu.com/