开发者学堂课程【ElasticSearch 最新快速入门教程:返回 account_number】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/642/detail/10675
返回 account_number
内容介绍:
一、返回 account_number=20
二、address=mill
三、address=mill lane
四、短语搭配 address=mill lane
一、返回 account_number=20
curl-XPOST’localhost:9200/bank/search?pretty’-d
‘{
“query”:{match_all”:{}},
“source”:{{“balance”,”account_number”}}
}’
match 查询,可以作为基本字段搜索查询
返回account_number=20:
curl-XPOST’localhost:9200/bank/_search?pretty’-d
‘{
“query”:{“match”:{“account_number”:20}},
}’
查询代码:
{
“query”:{
“match": {
“account_number”:20
}
},
“_source”:{
“_score”,
“balance”
“account_number”
},
“sort”:{
"balance": {
“order":”desc”
}
}
}
查询结果:
{
"took":111,
"timed_out": false,
▼
“_shards":{
"total":5,
"successful": 5,
"skipped": 0,
"failed":0
},
"hits":{
"total": 1,
"max_score": null,
"hits":{
{
"_index": "bank",
“_type":"account"
“_id":"20",
“_score": null,
“_source":{
"account_number":20,
"balance":16418
}
"sort";{
16418
}
查询所有的,代码如下:
{
“query”:{
“match": {
“account_number”:20
}
},
“sort”:{
"balance": {
“order":”desc”
}
}
}
查询结果:
二、返回 address=mill
curl-XPOST’localhost:9200/bank/search?pretty’-d
‘{
“query”:{match_all”:{}},
“source”:{{“balance”,”account_number”}}
}’
返回address=mill
curl-XPOST’localhost:9200/bank/_search?pretty’-d
‘{
“query”:{“match”:{“address”:”mill”}},
}
查询代码:
“query”:{
“match": {
“address”:”mill”
}
},
“sort”:{
"balance": {
“order":”desc”
}
}
}
查询结果:
三、返回 address=mill or address=lane
curl-XPOST’localhost:9200/bank/search?pretty’-d
‘{
“query”:{match_all”:{}},
“source”:{{“balance”,”account_number”}}
}’
返回 address=mill or address=lane
curl-XPOST’localhost:9200/bank/_search?pretty’-d
‘{
“query”:{“match”:{“address”:”mill lane”}},
}
查询代码1:
“query”:{
“match": {
“address”:”mill lane”
}
},
“sort”:{
"balance": {
“order":”desc”
}
}
}
查询结果:
查询代码2:
“query”:{
“match": {
“address”:”mill lane”
}
},
“sort”:{
"balance": {
“order":”desc”
}
},
“size”:200
}
查询结果:
四、返回 短语搭配 address=mill lane
curl-XPOST’localhost:9200/bank/search?pretty’-d
‘{
“query”:{match_all”:{}},
“_source”:{“balance”,”account_number”}
}’
返回 短语搭配 address=mill lane
curl-XPOST’localhost:9200/bank/_search?pretty’-d
‘{
“query”:{“match_phrase”:{“address”:”mill lane”}},
}
查询代码:
“query”:{
“match": {
“address”:”mill lane”
}
},
“sort”:{
"balance": {
“order":”desc”
}
},
“size”:200
“_source”:{
“balance”,
”account_number”
}
}
查询结果: