内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Elasticsearch常用操作API-創(chuàng)新互聯(lián)

1. 查詢所有的索引

成都創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:做網(wǎng)站、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的東海網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
[root@Server01 cx]# curl '10.0.0.5:9200/_cat/indices?v'
health status index    pri rep docs.count docs.deleted store.size pri.store.size 
yellow open   customer   5   1          2            0      6.6kb          6.6kb 
yellow open   bank       5   1       1000            0    442.1kb        442.1kb

2. 查詢bank表中的所有數(shù)據(jù)

[root@Server01 cx]# curl '10.0.0.5:9200/bank/_search?q=*&pretty'
{
  "took" : 41,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1000,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "25",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 25,
        "balance" : 40540,
        "firstname" : "Virginia",
        "lastname" : "Ayala",
        "age" : 39,
        "gender" : "F",
        "address" : "171 Putnam Avenue",
        "employer" : "Filodyne",
        "email" : "virginiaayala@filodyne.com",
        "city" : "Nicholson",
        "state" : "PA"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "44",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 44,
        "balance" : 34487,
        "firstname" : "Aurelia",
        "lastname" : "Harding",
        "age" : 37,
        "gender" : "M",
        "address" : "502 Baycliff Terrace",
        "employer" : "Orbalix",
        "email" : "aureliaharding@orbalix.com",
        "city" : "Yardville",
        "state" : "DE"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "99",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 99,
        "balance" : 47159,
        "firstname" : "Ratliff",
        "lastname" : "Heath",
        "age" : 39,
        "gender" : "F",
        "address" : "806 Rockwell Place",
        "employer" : "Zappix",
        "email" : "ratliffheath@zappix.com",
        "city" : "Shaft",
        "state" : "ND"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "119",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 119,
        "balance" : 49222,
        "firstname" : "Laverne",
        "lastname" : "Johnson",
        "age" : 28,
        "gender" : "F",
        "address" : "302 Howard Place",
        "employer" : "Senmei",
        "email" : "lavernejohnson@senmei.com",
        "city" : "Herlong",
        "state" : "DC"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "126",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 126,
        "balance" : 3607,
        "firstname" : "Effie",
        "lastname" : "Gates",
        "age" : 39,
        "gender" : "F",
        "address" : "620 National Drive",
        "employer" : "Digitalus",
        "email" : "effiegates@digitalus.com",
        "city" : "Blodgett",
        "state" : "MD"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "145",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 145,
        "balance" : 47406,
        "firstname" : "Rowena",
        "lastname" : "Wilkinson",
        "age" : 32,
        "gender" : "M",
        "address" : "891 Elton Street",
        "employer" : "Asimiline",
        "email" : "rowenawilkinson@asimiline.com",
        "city" : "Ripley",
        "state" : "NH"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "183",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 183,
        "balance" : 14223,
        "firstname" : "Hudson",
        "lastname" : "English",
        "age" : 26,
        "gender" : "F",
        "address" : "823 Herkimer Place",
        "employer" : "Xinware",
        "email" : "hudsonenglish@xinware.com",
        "city" : "Robbins",
        "state" : "ND"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "190",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 190,
        "balance" : 3150,
        "firstname" : "Blake",
        "lastname" : "Davidson",
        "age" : 30,
        "gender" : "F",
        "address" : "636 Diamond Street",
        "employer" : "Quantasis",
        "email" : "blakedavidson@quantasis.com",
        "city" : "Crumpler",
        "state" : "KY"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "208",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 208,
        "balance" : 40760,
        "firstname" : "Garcia",
        "lastname" : "Hess",
        "age" : 26,
        "gender" : "F",
        "address" : "810 Nostrand Avenue",
        "employer" : "Quiltigen",
        "email" : "garciahess@quiltigen.com",
        "city" : "Brooktrails",
        "state" : "GA"
      }
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "222",
      "_score" : 1.0,
      "_source" : {
        "account_number" : 222,
        "balance" : 14764,
        "firstname" : "Rachelle",
        "lastname" : "Rice",
        "age" : 36,
        "gender" : "M",
        "address" : "333 Narrows Avenue",
        "employer" : "Enaut",
        "email" : "rachellerice@enaut.com",
        "city" : "Wright",
        "state" : "AZ"
      }
    } ]
  }
}
  • took –  Elasticsearch執(zhí)行查詢的毫秒響應(yīng)時(shí)間

  • timed_out – 是否超時(shí)

  • _shards – 查詢過的分片,包含成功的分片和失敗的分片

  • hits – 搜索結(jié)果

  • hits.total – 符合搜索結(jié)果的記錄數(shù)

  • hits.hits – 默認(rèn)顯示前10條搜索結(jié)果

  • _score and max_score - ignore these fields for now

3. 另外一種查詢?nèi)拷Y(jié)果的方法

curl -XPOST '10.0.0.5:9200/bank/_search?pretty' -d '
{
  "query": { "match_all": {} }
}'

4. 分頁(yè)排序的檢索例子

[root@Server01 cx]# curl -XPOST '10.0.0.5:9200/bank/_search?pretty' -d '
{
  "query": { "match_all": {} },
  "from": 10,
  "size": 3,
  "sort": { "balance": { "order": "desc" } }
}'
{
  "took" : 8,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1000,
    "max_score" : null,
    "hits" : [ {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "255",
      "_score" : null,
      "_source" : {
        "account_number" : 255,
        "balance" : 49339,
        "firstname" : "Iva",
        "lastname" : "Rivers",
        "age" : 38,
        "gender" : "M",
        "address" : "470 Rost Place",
        "employer" : "Mantrix",
        "email" : "ivarivers@mantrix.com",
        "city" : "Disautel",
        "state" : "MD"
      },
      "sort" : [ 49339 ]
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "524",
      "_score" : null,
      "_source" : {
        "account_number" : 524,
        "balance" : 49334,
        "firstname" : "Salas",
        "lastname" : "Farley",
        "age" : 30,
        "gender" : "F",
        "address" : "499 Trucklemans Lane",
        "employer" : "Xumonk",
        "email" : "salasfarley@xumonk.com",
        "city" : "Noxen",
        "state" : "AL"
      },
      "sort" : [ 49334 ]
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "751",
      "_score" : null,
      "_source" : {
        "account_number" : 751,
        "balance" : 49252,
        "firstname" : "Patrick",
        "lastname" : "Osborne",
        "age" : 23,
        "gender" : "M",
        "address" : "915 Prospect Avenue",
        "employer" : "Gynko",
        "email" : "patrickosborne@gynko.com",
        "city" : "Takilma",
        "state" : "MO"
      },
      "sort" : [ 49252 ]
    } ]
  }
}

5. 添加文檔,如果id存在則更新文檔

[root@Server01 data]# curl -XPUT '10.0.0.5:9200/customer/external/1?pretty' -d '
> {"name":"John Doe"}'
{
  "_index" : "customer",
  "_type" : "external",
  "_id" : "1",
  "_version" : 1,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "created" : true
}
[root@Server01 data]# curl -XPUT '10.0.0.5:9200/customer/external/1?pretty' -d '
{"name":"Jane Doe"}'
{
  "_index" : "customer",
  "_type" : "external",
  "_id" : "1",
  "_version" : 2,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "created" : false
}

6. 不指定Id時(shí)創(chuàng)建文檔,可以發(fā)現(xiàn)自動(dòng)生成一個(gè)隨機(jī)Id

[root@Server01 data]# curl -XPOST '10.0.0.5:9200/customer/external?pretty' -d '{"name": "Jane Doe"}'
{
  "_index" : "customer",
  "_type" : "external",
  "_id" : "AVTh63KZ4Pj5B2ZQ2voK",
  "_version" : 1,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "created" : true
}

7. 修改文檔

[root@Server01 data]# curl -XPOST '10.0.0.5:9200/customer/external/2/_update?pretty' -d '{"doc":{"name":"favourite boy","age":18}}'
{
  "_index" : "customer",
  "_type" : "external",
  "_id" : "2",
  "_version" : 3,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  }
}

8. 在開啟javascript后,可以使用JS腳本更新文檔

[root@Server01 data]# curl -XPOST '10.0.0.5:9200/customer/external/2/_update?pretty' -d '{"script":"ctx._source.age+=5"}'

9. 刪除文檔

[root@Server01 data]# curl -XDELETE '10.0.0.5:9200/customer/external/1?pretty'
{
  "found" : true,
  "_index" : "customer",
  "_type" : "external",
  "_id" : "1",
  "_version" : 4,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  }
}

10. 批量更新文檔

[root@Server01 data]# curl -XPOST '10.0.0.5:9200/customer/external/_bulk?pretty' -d '
{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }'
{
  "took" : 33,
  "errors" : false,
  "items" : [ {
    "index" : {
      "_index" : "customer",
      "_type" : "external",
      "_id" : "1",
      "_version" : 3,
      "_shards" : {
        "total" : 2,
        "successful" : 1,
        "failed" : 0
      },
      "status" : 200
    }
  } ]
}
[root@Server01 data]# curl -XPOST '10.0.0.5:9200/customer/external/_bulk?pretty' -d '
> {"update":{"_id":"1"}}
> {"doc": { "name": "John Doe becomes Jane Doe" } }
> {"delete":{"_id":"2"}}
> '
{
  "took" : 34,
  "errors" : false,
  "items" : [ {
    "update" : {
      "_index" : "customer",
      "_type" : "external",
      "_id" : "1",
      "_version" : 4,
      "_shards" : {
        "total" : 2,
        "successful" : 1,
        "failed" : 0
      },
      "status" : 200
    }
  }, {
    "delete" : {
      "_index" : "customer",
      "_type" : "external",
      "_id" : "2",
      "_version" : 5,
      "_shards" : {
        "total" : 2,
        "successful" : 1,
        "failed" : 0
      },
      "status" : 200,
      "found" : true
    }
  } ]
}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)站題目:Elasticsearch常用操作API-創(chuàng)新互聯(lián)
文章起源:http://www.rwnh.cn/article2/cspiic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、ChatGPT外貿(mào)建站、標(biāo)簽優(yōu)化、網(wǎng)站設(shè)計(jì)靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司
阜宁县| 荔波县| 娄烦县| 南投市| 灵宝市| 沂水县| 肃宁县| 磐安县| 政和县| 新田县| 应用必备| 永修县| 监利县| 库尔勒市| 旌德县| 宣武区| 夏河县| 云阳县| 建平县| 任丘市| 金秀| 永年县| 澄迈县| 和田市| 广宁县| 蒙山县| 达拉特旗| 兰西县| 赫章县| 铅山县| 盐亭县| 齐河县| 莫力| 凤阳县| 瓮安县| 界首市| 乐陵市| 亳州市| 邹城市| 克什克腾旗| 安岳县|