日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

批量查询,mget语法,mget批量查询(来自学习资料,第26节)

發(fā)布時間:2024/9/27 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 批量查询,mget语法,mget批量查询(来自学习资料,第26节) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、批量查詢的好處

一條一條的查詢,比如說要查詢100條數(shù)據(jù),那么就要發(fā)送100次網(wǎng)絡(luò)請求,這個開銷還是很大的
如果進(jìn)行批量查詢的話,查詢100條數(shù)據(jù),就只要發(fā)送1次網(wǎng)絡(luò)請求,網(wǎng)絡(luò)請求的性能開銷縮減100倍,這時候就可以使用mget來完成這個目標(biāo)

2、mget的語法

(1)一條一條的查詢

GET /test_index/test_type/1

運(yùn)行的結(jié)果是:

{"_index": "test_index","_type": "test_type","_id": "1","_version": 2,"found": true,"_source": {"test_field1": "test field1","test_field2": "test field2"} }

再如:

GET /test_index/test_type/2

運(yùn)行的結(jié)果是:

{"_index": "test_index","_type": "test_type","_id": "2","_version": 1,"found": true,"_source": {"test_content": "my test"} }

(2)mget批量查詢

查詢語句:

GET /_mget {"docs" : [{"_index" : "test_index","_type" : "test_type","_id" : 1},{"_index" : "test_index","_type" : "test_type","_id" : 2}] }

查詢結(jié)果:

{"docs": [{"_index": "test_index","_type": "test_type","_id": "1","_version": 2,"found": true,"_source": {"test_field1": "test field1","test_field2": "test field2"}},{"_index": "test_index","_type": "test_type","_id": "2","_version": 1,"found": true,"_source": {"test_content": "my test"}}] }

(3)如果查詢的document是一個index下的不同type種的話

查詢語句: {"docs": [{"_index": "test_index","_type": "test_type","_id": "1","_version": 2,"found": true,"_source": {"test_field1": "test field1","test_field2": "test field2"}},{"_index": "test_index","_type": "test_type","_id": "2","_version": 1,"found": true,"_source": {"test_content": "my test"}}] }

(4)如果查詢的數(shù)據(jù)都在同一個index下的同一個type下,最簡單了

查詢語句

GET /test_index/test_type/_mget {"ids": [1, 2] }

3、mget的重要性

可以說mget是很重要的,一般來說,在進(jìn)行查詢的時候,如果一次性要查詢多條數(shù)據(jù)的話,那么一定要用batch批量操作的api
盡可能減少網(wǎng)絡(luò)開銷次數(shù),可能可以將性能提升數(shù)倍,甚至數(shù)十倍,非常非常之重要

總結(jié)

以上是生活随笔為你收集整理的批量查询,mget语法,mget批量查询(来自学习资料,第26节)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。