文檔 Document
我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、武清ssl等。為上千多家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的武清網(wǎng)站制作公司Json Object,有字段(field)組成,常見數(shù)據(jù)類型如下:
每個(gè)文檔都有一個(gè)唯一的ID標(biāo)識(shí)
元數(shù)據(jù)(MetaData),用于標(biāo)注文檔相關(guān)信息
單詞詞典(Term Dictionary)是倒排索引的重要組成
倒排列表( Posting List )記錄了單詞對(duì)應(yīng)的文檔集合,由倒排索引項(xiàng)( Posting )組成
倒排索引項(xiàng)( Posting )主要包含如下信息:
索引中存儲(chǔ)具有相同結(jié)構(gòu)的文檔(Document)
一個(gè)集群可以有多個(gè)索引,比如:
Elasticsearch 集群對(duì)外提供RESTful API
es有專門的Index API,用于創(chuàng)建,更新,刪除索引配置等
PUT /test_index
GET_cat/indices
es有專門的 Document API
指定文檔ID創(chuàng)建文檔:
PUT /test_index/doc/1
{
"username":"kibana",
"version":6.1
}
POST /test1_index/doc
{
"username":"kibana",
"version":6.1
}
GET /test_index/doc/1
GET /test_index/doc/_search //不指定條件查找
GET /test_index/doc/_search
{
"query": {
"term":{
"_id":"1" //指定條件,查找ID為1的文檔
}
}
}
es允許一次操作多個(gè)文檔(增刪改查,create創(chuàng)建文檔,如果文檔已經(jīng)存在就會(huì)報(bào)錯(cuò)。index創(chuàng)建文檔,如果存在就會(huì)覆蓋。)
POST _bulk
{"index":{"_index":"test_index","_type":"doc","_id":"3"}}
{"username":"zabbix","version":4}
{"delete":{"_index":"test_index","_type":"doc","_id":"1"}}
{"update":{"_id":"4","_index":"test_index","_type":"doc"}}
{"doc":{"es":"5.0"}}
輸出:
{
"took": 979, //查詢耗時(shí),單位ms
"errors": false, //返回結(jié)果,正確或錯(cuò)誤
"items": [ //每個(gè)操作返回的結(jié)果
{
"index": {
"_index": "test_index",
"_type": "doc",
"_id": "3",
"_version": 1,
"result": "created", //創(chuàng)建
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1,
"status": 201
}
},
{
"delete": {
"_index": "test_index",
"_type": "doc",
"_id": "1",
"_version": 2,
"result": "deleted", //刪除
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 1,
"_primary_term": 1,
"status": 200
}
},
{
"update": {
"_index": "test_index",
"_type": "doc",
"_id": "4",
"_version": 2,
"result": "updated", //更改
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 3,
"_primary_term": 1,
"status": 200
}
}
]
}
GET /_mget //查找在test_index索引,id為4和1的文檔.
{
"docs":[ //指明要查詢的文檔id
{
"_index":"test_index",
"_type":"doc",
"_id":"4"
},
{
"_index":"test_index",
"_type":"doc",
"_id":"2"
}
]
}
返回
{
"docs": [
{
"_index": "test_index",
"_type": "doc",
"_id": "4",
"_version": 2,
"found": true,
"_source": {
"username": "es",
"version": 6.1,
"es": "5.0"
}
},
{
"_index": "test_index",
"_type": "doc",
"_id": "2",
"_version": 1,
"found": true,
"_source": {
"username": "zabbix",
"version": 4.2
}
}
]
}
歡迎加入
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。