//查询index topic123
curl -H "Content-Type: application/json" -XPOST localhost:9200/topic123/_search?pretty
//创建索引
curl -XPUT "http://localhost:9200/people?include_type_name=true" -H "Content-Type:application/json" -d "{\"settings\":{\"index.number_of_shards\":3,\"index.number_of_replicas\":1},\"mappings\":{\"_doc\":{\"properties\":{\"name\":{\"type\":\"keyword\"},\"age\":{\"type\":\"integer\"}}}}}"
//插入数据
curl -XPUT "http://localhost:9200/people/_doc/1" -H "Content-Type:application/json" -d "{\"name\":\"zhangsan\",\"age\": 21}"
//查询数据
curl -XGET "http://localhost:9200/people/_doc/1"
windows 下 执行 curl 命令 如果命令中包含 json字符串,字符串中 双引号 需要加 转义
-d 后 第一个双引号 不加转义
最后一个双引号 不加转义
调用git 命令行执行 避免以上问题,dos下不支持多行输入,调用git命令行可以多行输入
例子参考
curl -XPUT http://localhost:9200/bigdata_p
curl -H "Content-Type: application/json" -XPOST http://localhost:9200/bigdata_p/product/ -d '{"author" : "Doug Cutting"}'
curl -H "Content-Type: application/json" -XPOST http://localhost:9200/bigdata_p/product/ -d '{"name":"hadoop","author":"Doug Cutting","c_version":"2.7.3"}'
curl -XGET http://localhost:9200/bigdata_p/_search?pretty
curl -XGET http://localhost:9200/bigdata_p/product/_search?pretty
curl -XGET http://localhost:9200/bigdata_p/product/1?pretty
curl -XGET http://localhost:9200/bigdata_p/product/1?_source=name&pretty
curl -XGET http://localhost:9200/bigdata_p/product/1?_source=name,author&pretty
curl -XGET http://localhost:9200/bigdata_p/product/1?_source&pretty
curl -H "Content-Type: application/json" -XGET http://localhost:9200/_search?pretty -d '
{
"query": {
"multi_match": {
"type": "most_fields",
"query": "111",
"fields": [ "title", "title.english" ]
}
}
}'
http://127.0.0.1:9200/_cat/indices?v
https://127.0.0.1:9200/topic123/_search?pretty
curl http://127.0.0.1:9200/topic123/_search?pretty
http://127.0.0.1:9200/_cat/indices?v
curl -H "Content-Type: application/json" -XPOST localhost:9200/topic123/_search?pretty
curl -XPUT "http://localhost:9200/people?include_type_name=true" -H "Content-Type:application/json" -d "{\"settings\":{\"index.number_of_shards\":3,\"index.number_of_replicas\":1},\"mappings\":{\"_doc\":{\"properties\":{\"name\":{\"type\":\"keyword\"},\"age\":{\"type\":\"integer\"}}}}}"
curl -XPUT "http://localhost:9200/people/_doc/1" -H "Content-Type:application/json" -d "{\"name\":\"zhangsan\",\"age\": 21}"
curl -XGET "http://localhost:9200/people/_doc/1"