开发者学堂课程【ElasticSearch 入门精讲:通过 REST 请求 URI】学习笔记,与课程紧密连接,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/631/detail/10017
通过 REST 请求 URI
ES Rest 之通过 REST 请求 URI
curl’http://localhost:9200/bank/_search?q=&pretty’
q=:参数告诉 elasticsearch,在 bank 索引中匹配所有的文档
pretty:参数告诉 elasticsearch,返回形式打印 JSON 结果
查询 http://janson01:9200/bank/_search/
q=&preetyPOST
提交请求后
{
"error": {
"root_cause": [
{
"type": "invalid_type_name_exception",
"reason": "Document mapping type name can't start with '_’, found: [_search]"
}
],
"type": "invalid_type_name_exception",
"reason": "Document mapping type name can't start with '_’, found: [_search]”
},
"status": 400
}
查询 http://janson01:9200/bank/_search/
q=&preety GET
提交请求后
{
“_index": "bank",
“_type": "_search",
“_id": "q=&preety",
“found”:false
}
查询 http://janson01:9200/bank/
_search?preety GET
(如果带条件可以在 q=&preety 后加上 &q=)
提交请求后
{
"took": 33,
"timed_out": false,
"_shards": {
"total": 5,
"successful”: 5,
"skipped": 0 ,
"failed": 0
},
"hits": {
“total": 1000,
"max_score": 1 ,
"hits": [
{
“_index": "bank",
“_ type": "account",
“_id": "25",
“_score": 1,
“_source": {
“account_number": 25 ,
“balance": 40540,
"firstname": "Virginia”,
"lastname": "Ayala”,
"age": 39,
"gender": "F",
"address": "171 Putnam Avenue",
"employer": "Filodyne",
"email":
"virginlaayala@filodyne.com"
“city”:”Nicholson”,
"state": "PA"
}
}
,
{
“_index": "bank"
“_type": "account"
“_id": "44”,
“_score": 1,
“_source": {
"account_number": 44,
"balance": 34487,
"firstname": "Aurelia",
"lastname": "Harding”,
"age": 37,
"gender": "M",
"address": "502 Baycliff Terrace",
"employer": "Orbalix",
"email:
"aureliaharding@orbalix.com",
"city": "Yardville”,
"state": "DE"
}
}