查索引内所有文档记录
GET /beauties/my/_search
GET /beauties/my/_search
{
"query":{
"match_all": {}
}
}
匹配、排序
GET /beauties/my/_search
{
"query": {
"match": {
"Name": "Ruru"
}
},
"sort": [
{"Age": "desc"}
]
}
筛选字段
GET /beauties/my/_search
{
"query": {
"match_all": {}
},
"_source":["Name","Age"]
}
分页
GET /beauties/my/_search
{
"query": {
"match_all": {}
},
"_source":["Name","Age"],
"from": 1,
"size": 2
}
bool filter、
GET /beauties/my/_search
{
"query": {
"bool": {
"must": {
"match": {
"Name": "Zhao"
}
},
"filter":{
"range": {
"Age": {
"gt": 19,
"lt":24
}
}
}
}
}
}
GET /beauties/my/5
POST /beauties/my/5/_update
{
"doc":{
"Desc":"Ruru Friend"
}
}
全文检索:会匹配Name的值,包含以下单词的,只要匹配一个单词就能搜出来,但score不一样
GET /beauties/my/_search
{
"query": {
"match": {
"Name": "Zhao Ruru Chang Aijing Wei"
}
}
}
短语搜索:必须匹配 Zhao Ruru才行。
对于Name=Zhao Ruru的记录,搜match_phrase=Zhao能搜出来,=Zha搜不出来
GET /beauties/my/_search
{
"query": {
"match_phrase": {
"Name": "Zhao Ruru"
}
}
}
高亮匹配的关键词。会在结果中,给关键词加上 em 标签
GET /beauties/my/_search
{
"query": {
"match_phrase": {
"Name": "Zhao"
}
},
"highlight": {
"fields": {
"Name":{}
}
}
}