前言
一、进阶检索-两种查询方式
配置es和kibana自动重启
docker update f5d --restart=always
docker update ba4 --restart=always
确认启动es和kibana
使用参考es官网文档
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/index.html
1. Search API
#_search 查询,* 查询所有,sort 按照account_number升序搜索
GET bank/_search?q=*&sort=account_number:asc //方法一。设置根据account_number升序搜索
2. Query DSL
参考文档 https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-filter-context.html
GET /bank/_search
{
"query": {
"match_all": {}
},
"sort": [
{
"account_number": "asc"
},
{
"balance": "desc"
}
]
}
Query DSL基本使用&match_all
GET /bank/_search
{
#全量查询
"query": {
"match_all": {}
},
#按字段排序
"sort": [
{
"balance": {
"order": "desc" #降序
}
}
],
#分页0开始 5个数据
"from": 0,
"size": 5,
#指定部分数据
"_source": ["account_number","age"]
}
match全文检索
参考文档
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/getting-started-search.html
##全文检索,会按照评分max_score进行排序
GET bank/_search
{
"query": {
"match": {
"address": "mill"
}
}
}
match_phrase短语匹配
multi_match多字段匹配
##多字段匹配
GET /bank/_search
{
"query": {
"multi_match": {
"query": "mill Lopezo",
"fields": ["address","city"]
}
}
}
参考文档: https://www.elastic.co/guide/en/elasticsearch/reference/7.4/getting-started-search.html