1、mapping获取
GET book/_mapping
2、match_all——查询所有
GET book/_search
{
"query":{
"match_all": {}
}
}
3、查询数据的范围
GET book/_search
{
"from":0,
"size": 10
}
4、排序
GET book/_search
{
"sort": [
{
"created_date": {"order": "desc"}
}
]
}
5、返回总数量
GET book/_search
{
"track_total_hits": 2147483647
}
6、返回指定列,剔除指定列
GET book/_search
{
"_source": {
"includes": [
"id"
],
"excludes": ["time"]
}
}
7、筛选数据
terms 等同于mysql的in
term 等同于mysql的=
下面的示例:查询id in(“2a7e6e7aee4948829ee302c0eb6f882a”,“d4d03625a912414eb33617e9603db7e1”)and product =‘NetWork,Storage’
GET book/_search
{
"from": 0,
"size": 10,
"query": {
"bool": {
"filter": [
"term": {
"product": {
"value": "NetWork,Storage",
"boost": 1.0
}
},
"terms": {
"id": [
"2a7e6e7aee4948829ee302c0eb6f882a",
"d4d03625a912414eb33617e9603db7e1"
],
"boost": 1.0
}
]
}
"_source": {
"includes": [
"id"
],
"excludes": []
},
"track_total_hits": 2147483647
}
8、模糊搜索
9、or
10、sum
GET betam_hc_self_cbccrmasstsalesservicedb.v_report_account_v2_gray/_search
{
"query": {
"bool": {
"filter": [
{
"terms": {
"t_account_cdhnumber": [
"102208020","1003391365"
],
"boost": 1.0
}
}
],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"aggs": {
"sum_number": {
"sum": {
"field": "t_account_operational_excellence"
}
},
"sum_number2": {
"sum": {
"field": "t_account_legalflagcode"
}
}
}
}