多索引、多类型查询:

# curl -H’content-type: application/json’ -XPUT ‘node1:9200/students1/class2/1?pretty’ -d ‘
{
“name”:”huang rong”,
“gender”:”Male”,
“age”:23,
“class”:”Gumu Pai”
}’
# curl -H’content-type: application/json’ -XPUT ‘node1:9200/students1/class2/2?pretty’ -d ‘
{
“name”:”Huang yaoshi”,
“gender”:”Female”,
“age”:48,
“class”:”Taohuadao”
}’
# curl -H’content-type: application/json’ -XPUT ‘node1:9200/students1/class2/4?pretty’ -d ‘
{
“name”:”Guo jing”,
“gender”:”Female”,
“age”:38,
“class”:”Gai Bang”
}’
# curl -H’content-type: application/json’ -XPUT ‘node1:9200/students1/class2/3?pretty’ -d ‘
{
“name”:”Guo xiang”,
“gender”:”Female”,
“age”:20,
“class”:”Huang Bang”
}’
# curl -H “content-type: application/json” -XGET ‘node1:9200/students1/class2/_search?pretty’ -d ‘
{
“query”:{ “match_all” : { } }
}’
{
“took” : 65,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 3,
“max_score” : 1.0,
“hits” : [
{
“_index” : “students1”,
“_type” : “class2”,
“_id” : “2”,
“_score” : 1.0,
“_source” : {
“name” : “Huang yaoshi”,
“gender” : “Female”,
“age” : 48,
“class” : “Taohuadao”
}
},
{
“_index” : “students1”,
“_type” : “class2”,
“_id” : “1”,
“_score” : 1.0,
“_source” : {
“name” : “huang rong”,
“gender” : “Male”,
“age” : 23,
“class” : “Gumu Pai”
}
},
{
“_index” : “students1”,
“_type” : “class2”,
“_id” : “3”,
“_score” : 1.0,
“_source” : {
“name” : “Guo jing”,
“gender” : “Female”,
“age” : 38,
“class” : “Gai Bang”
}
}
]
}
}

/_search:所有索引;
# curl -H “content-type: application/json” -XGET ‘node1:9200/_search?pretty’ -d ‘
{
“query”:{ “match_all” : { } }
}’

“took” : 22,
“timed_out” : false,
“_shards” : {
“total” : 10,
“successful” : 10,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 5,
“max_score” : 1.0,
“hits” : [
{
“_index” : “students”,
“_type” : “class1”,
“_id” : “DB8jdmMB3-WOr5XzU2E0”,
“_score” : 1.0,
“_source” : {
“first name” : “Zhong”,
“last name” : “Mingjia”,
“id” : “1”,
“gender” : “Female”,
“courses” : “Xiang Long Shi Ba Zhang”
}
},
{
“_index” : “students1”,
“_type” : “class2”,
“_id” : “2”,
“_score” : 1.0,
“_source” : {
“name” : “Huang yaoshi”,
“gender” : “Female”,
“age” : 48,
“class” : “Taohuadao”
}
},
….
/INDEX_NAME/_search:单索引;
# curl -H “content-type: application/json” -XGET ‘node1:9200/students/_search?pretty’ -d ‘
{
“query”:{ “match_all” : { } }
}’
{
“took” : 17,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 2,
“max_score” : 1.0,
“hits” : [
{
“_index” : “students”,
“_type” : “class1”,
“_id” : “DB8jdmMB3-WOr5XzU2E0”,
“_score” : 1.0,
“_source” : {
“first name” : “Zhong”,
“last name” : “Mingjia”,
“id” : “1”,
“gender” : “Female”,
“courses” : “Xiang Long Shi Ba Zhang”
}
},
{
“_index” : “students”,
“_type” : “class1”,
“_id” : “1”,
“_score” : 1.0,
“_source” : {
“first_name” : “Zhong”,
“last_name” : “MingJia”,
“gender” : “Female”,
“age” : 22,
“courses” : “Xiang Long Shi Ba Zhang”
}
}
]
}
}

/INDEX1,INDEX2/_search:多索引;
# curl -H “content-type: application/json” -XGET ‘node1:9200/students,students1/_search?pretty’ -d ‘
{
“query”:{ “match_all” : { } }
}’

/s*,t*/_search:
# curl -H “content-type: application/json” -XGET ‘node1:9200/stud*/_search?pretty’ -d ‘
{
“query”:{ “match_all” : { } }
}’

/students/class1/_search:单类型搜索
# curl -H “content-type: application/json” -XGET ‘node1:9200/students/class1/_search?pretty’ -d ‘
{
“query”:{ “match_all” : { } }
}’
/students/class1,class2/_search:多类型搜索
# curl -H “content-type: application/json” -XGET ‘node1:9200/students/class1,class2/_search?pretty’ -d ‘
{
“query”:{ “match_all” : { } }
}’

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值