最近由于项目中使用ES,对照《Elasticsearch: 权威指南》进行学习,将一些知识进行整理总结。
##插入一条记录
PUT /megacorp/employee/1
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}
PUT /megacorp/employee/2
{
"first_name" : "Jane",
"last_name" : "Smith",
"age" : 32,
"about" : "I like to collect rock albums",
"interests": [ "music" ]
}
PUT /megacorp/employee/3
{
"first_name" : "Douglas",
"last_name" : "Fir",
"age" : 35,
"about": "I like to build cabinets",
"interests": [ "forestry" ]
}
##根据ID查询
GET megacorp/employee/1
##查询全部数据
GET megacorp/employee/_search
##查询last_name为Smith的记录(使用query-string)
GET /megacorp/employee/_search?q=last_name:Smith
##查询last_name为Smith的记录(使用DSL)
GET /megacorp/employee/_search
{
"query

本文介绍了在项目中使用ES时,根据《Elasticsearch: 权威指南》学习的基础查询语句,旨在整理和总结关键知识点。
最低0.47元/天 解锁文章
3472

被折叠的 条评论
为什么被折叠?



