Search调用
/index1/_search
/index1,index2/_search
/index*/_search
URI Search
get /users/_search?q=is&df=message&sort=post_date:desc&from=3&size=10&timeout=1s
{
"profile":true
}
- q:查询字符串
- df:查询字段,不指定默认所有字段
- sort:排序字段(from,size,分页相关)
- profile:true/false:展示search过程
另外一种形式:
get /users/_search?q=message:is
search message,包含is字符
Request Body Search
get /users/_search
{
"profile":true,
"sort":
{
"post_date":
{
"order":"desc"
}
},
"from":"3",
"size":1,
"query":{
"match_all": {}
}
}
get /users/_search
{
"profile":true,
"sort":
{
"post_date":
{
"order":"desc"
}
},
"from":"3",
"query":{
"bool": {
"must": [
{"match":
{
"user": "mike"
}
},
{"match_phrase":
{
"message": "is"
}
}
]
}
}
}