查询指定id信息 GET /index_name/_doc/1074266245 查询指定信息并降序 GET /index_name/_search { "query": { "term": { "deviceId": { "value": "1074266245" } } }, "sort": [ { "timestamp": { "order": "desc" } } ] } //多条件查询 GET /index_name/_search { "query": { "bool": { "must": [ { "term": { "payload.locator_dev_id": { "value": 100902 } } }, { "term": { "payload.dev_id": { "value": 100301 } } } ] } }, "sort": [ { "timestamp": { "order": "desc" } } ] } //自定字段去重查询 GET /index_name/_search { "query": { "term": { "bodyObj.payLoad.dev_id": { "value": "100101" } } }, "collapse": { "field": "bodyObj.payLoad.key" }, "from": 0, "size": 10, "track_total_hits": true, "aggs": { "courseAgg": { "cardinality": { "field": "bodyObj.payLoad.key" } } } } //修改指定字段值 POST /index_name/_update/101202 { "doc": { "category":"2" } } #指定字段必须存在或不存在 GET /index_name/_search { "query": { "bool": { "must": [ { "exists": { "field": "deviceId" } } ] } }, "sort": [ { "timestamp": { "order": "desc" } } ] } 条件查询并排序
GET /table_index/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"dev_id": "100101"
}
},
{
"range": {
"timestamp": {
"lte": 1702434986000
}
}
}
]
}
},
"sort": [
{
"timestamp": {
"order": "desc"
}
}
]
}
文章来源地址https://www.toymoban.com/news/detail-768686.html
文章来源:https://www.toymoban.com/news/detail-768686.html
到了这里,关于es常用查询编辑的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!