查詢指定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"
}
}
]
}
文章來源地址http://www.zghlxwxcb.cn/news/detail-768686.html
文章來源:http://www.zghlxwxcb.cn/news/detail-768686.html
到了這里,關(guān)于es常用查詢編輯的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!