├── .dockerignore ├── _benchmarks ├── .gitignore ├── scripts │ └── run-benchmarks ├── benchmarks │ └── go.mod └── README.md ├── _examples ├── xkcdsearch │ ├── .dockerignore │ ├── .gitignore │ ├── screenshot.png │ ├── web │ │ └── assets │ │ │ ├── images │ │ │ ├── left.png │ │ │ ├── right.png │ │ │ └── middle.png │ │ │ └── fonts │ │ │ └── xkcd-script.woff │ └── Makefile ├── instrumentation │ ├── .dockerignore │ ├── .gitignore │ ├── screenshot.png │ └── Makefile ├── bulk │ ├── .gitignore │ ├── kafka │ │ ├── screenshot.png │ │ └── .env │ ├── benchmarks │ │ └── data │ │ │ └── small │ │ │ ├── document.json │ │ │ └── mapping.json │ ├── Makefile │ └── go.mod ├── cloudfunction │ ├── .gitignore │ ├── .gcloudignore │ ├── screenshot.png │ ├── Makefile │ └── go.mod ├── encoding │ ├── .gitignore │ ├── screenshot.png │ └── Makefile ├── fasthttp │ ├── .gitignore │ └── Makefile ├── security │ ├── .gitignore │ ├── .env │ ├── certificates-config.yml │ └── go.mod ├── extension │ └── Makefile ├── go.mod ├── logging │ └── Makefile └── go.sum ├── esapi └── test │ ├── .gitignore │ └── go.mod ├── .gitignore ├── NOTICE ├── internal └── build │ └── cmd │ └── generate │ └── commands │ ├── gentests │ ├── .gitignore │ └── testdata │ │ └── info │ │ └── 20_lucene_version.yml │ └── gensource │ └── testdata │ └── info.json ├── CODE_OF_CONDUCT.md ├── .doc ├── images │ ├── es-endpoint.jpg │ └── create-api-key.png ├── typedapi │ ├── conventions │ │ ├── responses.asciidoc │ │ ├── naming.asciidoc │ │ ├── index.asciidoc │ │ ├── requests.asciidoc │ │ └── structure.asciidoc │ └── examples │ │ ├── index.asciidoc │ │ └── indices.asciidoc ├── examples │ └── doc │ │ ├── b02e4907c9936c1adc16ccce9d49900d.asciidoc │ │ ├── 3d1ff6097e2359f927c88c2ccdb36252.asciidoc │ │ ├── 1c23507edd7a3c18538b68223378e4ab.asciidoc │ │ ├── 12433d2b637d002e8d5c9a1adce69d3b.asciidoc │ │ ├── 67bba546d835bca8f31df13e3587c348.asciidoc │ │ ├── be8f28f31207b173de61be032fcf239c.asciidoc │ │ ├── cfc37446bd892d1ac42a3c8e8b204e6c.asciidoc │ │ ├── f8cc4b331a19ff4df8e4a490f906ee69.asciidoc │ │ ├── fbcf5078a6a9e09790553804054c36b3.asciidoc │ │ ├── 3f3b3e207f79303ce6f86e03e928e062.asciidoc │ │ ├── 98234499cfec70487cec5d013e976a84.asciidoc │ │ ├── 98f14fddddea54a7d6149ab7b92e099d.asciidoc │ │ ├── c5e5873783246c7b1c01d8464fed72c4.asciidoc │ │ ├── 89a8ac1509936acc272fc2d72907bc45.asciidoc │ │ ├── fabe14480624a99e8ee42c7338672058.asciidoc │ │ ├── 2468ab381257d759d8a88af1141f6f9c.asciidoc │ │ ├── a6fdd0100cd362df54af6c95d1055c96.asciidoc │ │ ├── dea22bb4997e368950f0fc80f2a5f304.asciidoc │ │ ├── a8fba09a46b2c3524428aa3259b7124f.asciidoc │ │ ├── cde4dddae5c06e7f1d38c9d933dbc7ac.asciidoc │ │ ├── be3a6431d01846950dc1a39a7a6a1faa.asciidoc │ │ ├── c2c21e2824fbf6b7198ede30419da82b.asciidoc │ │ ├── cf02e3d8b371bd59f0224967c36330da.asciidoc │ │ ├── 68738b4fd0dda177022be45be95b4c84.asciidoc │ │ ├── 1dbb8cf17fbc45c87c7d2f75f15f9778.asciidoc │ │ ├── 3e8ed6ae016eb823cb00d9035b8ac459.asciidoc │ │ ├── 4dac1d8953674f1640f2192a94dd1439.asciidoc │ │ ├── 621665fdbd7fc103c09bfeed28b67b1a.asciidoc │ │ ├── 1252fa45847edba5ec2b2f33da70ec5b.asciidoc │ │ ├── 138ccd89f72aa7502dd9578403dcc589.asciidoc │ │ ├── 18ddb7e7a4bcafd449df956e828ed7a8.asciidoc │ │ ├── 1d65cb6d055c46a1bde809687d835b71.asciidoc │ │ ├── d8b115341da772a628a024e7d1644e73.asciidoc │ │ ├── 52c7e4172a446c394210a07c464c57d2.asciidoc │ │ ├── 54a770f053f3225ea0d1e34334232411.asciidoc │ │ ├── bdb30dd52d32f50994008f4f9c0da5f0.asciidoc │ │ ├── 47b5ff897f26e9c943cee5c06034181d.asciidoc │ │ ├── 745f9b8cdb8e91073f6e520e1d9f8c05.asciidoc │ │ ├── a4a396cd07657b3977713fb3a742c41b.asciidoc │ │ ├── 710c7871f20f176d51209b1574b0d61b.asciidoc │ │ ├── 7df191cc7f814e410a4ac7261065e6ef.asciidoc │ │ ├── 1e18a67caf8f06ff2710ec4a8b30f625.asciidoc │ │ ├── 216848930c2d344fe0bed0daa70c35b9.asciidoc │ │ ├── 4ca7f48438b7391e535ba0b76f7df148.asciidoc │ │ ├── d90a84a24a407731dfc1929ac8327746.asciidoc │ │ ├── 1b542e3ea87a742f95641d64dcfb1bdb.asciidoc │ │ ├── 8eb4376d4ff2587d0f14e63a7fb29a2a.asciidoc │ │ ├── c48264ec5d9b9679fddd72e5c44425b9.asciidoc │ │ ├── d2146e521344c5baa4984cf9147f18f2.asciidoc │ │ ├── 04f5dd677c777bcb15d7d5fa63275fc8.asciidoc │ │ ├── 073539a7e38be3cdf13008330b6a536a.asciidoc │ │ ├── 69a7be47f85138b10437113ab2f0d72d.asciidoc │ │ ├── 72beebe779a258c225dee7b023e60c52.asciidoc │ │ ├── b9a153725b28fdd0a5aabd7f17a8c2d7.asciidoc │ │ ├── fe5763d32955e8b65eb3048e97b1580c.asciidoc │ │ ├── 2749644d98cd9bbb0831f9281c311851.asciidoc │ │ ├── 3227b17f70d3cb3a5f2b296d6943848a.asciidoc │ │ ├── 5925c23a173a63bdb30b458248d1df76.asciidoc │ │ ├── 8fdf2344c4fb3de6902ad7c5735270df.asciidoc │ │ ├── 866f52fbe17d4177a9f0d49c422b95ff.asciidoc │ │ ├── 8e6bfb4441ffa15c86d5dc20fa083571.asciidoc │ │ ├── c22b72c4a52ee098331b3f252c22860d.asciidoc │ │ ├── 09dbd90c5e22ea4a17b4cf9aa72e08ae.asciidoc │ │ ├── 427f6b5c5376cbf0f71f242a60ca3d9e.asciidoc │ │ ├── 9bae72e974bdeb56007d9104e73eff92.asciidoc │ │ ├── a0f4e902d18460337684d74ea932fbe9.asciidoc │ │ ├── e567e6dbf86300142573c73789c8fce4.asciidoc │ │ ├── 0cc991e3f7f8511a34730e154b3c5edc.asciidoc │ │ ├── 311c4b632a29b9ead63b02d01f10096b.asciidoc │ │ ├── bfcd65ab85d684d36a8550080032958d.asciidoc │ │ ├── 09d617863a103c82fb4101e6165ea7fe.asciidoc │ │ ├── 53d938c754f36a912fcbe6473abb463f.asciidoc │ │ ├── 6e000496a1fa8b57148518eaad692f35.asciidoc │ │ ├── d222c6a6ec7a3beca6c97011b0874512.asciidoc │ │ ├── eb14cedd3bdda9ffef3c118f3d528dcd.asciidoc │ │ ├── 344b4144244d57f87c6aa4652b100b25.asciidoc │ │ ├── a69b1ce5cc9528fb3639185eaf241ae3.asciidoc │ │ ├── 111c69ca94162c1523b799a5c14723dd.asciidoc │ │ ├── 41dbd79f624b998d01c10921e9a35c4b.asciidoc │ │ ├── 52b2bfbdd78f8283b6f4891c48013237.asciidoc │ │ ├── 339a47c843bd7ea9573bf8975918df2c.asciidoc │ │ ├── 5be23858b35043fcb7b50fe36b873e6e.asciidoc │ │ ├── 7b5c231526846f2f7b98d78f3656ae6a.asciidoc │ │ ├── b0fa301cd3c6b9db128e34114f0c1e8f.asciidoc │ │ ├── de876505acc75d371d1f6f484c449197.asciidoc │ │ ├── e4be53736bcc02b03068fd72fdbfe271.asciidoc │ │ ├── ebb6b59fbc9325c17e45f524602d6be2.asciidoc │ │ ├── 3b04cc894e6a47d57983484010feac0c.asciidoc │ │ ├── d63033fcb0b13eb9476eb13f567c160a.asciidoc │ │ ├── e21e1c26dc8687e7bf7bd2bf019a6698.asciidoc │ │ ├── 025b54db0edc50c24ea48a2bd94366ad.asciidoc │ │ ├── 3d1a0e1dc5310544d032108ae0b3f099.asciidoc │ │ ├── 3eddf4664660fccc9fb3102462009acb.asciidoc │ │ ├── a05e022599d1789e90ff3a41469b0b6d.asciidoc │ │ ├── b1efa1c51a34dd5ab5511b71a399f5b1.asciidoc │ │ ├── e8cbe2269f3dff6b231e73119e81511d.asciidoc │ │ ├── f1fafd45a69147795642f974e37e7ad0.asciidoc │ │ ├── 400e89eb46ead8e9c9e40f123fd5e590.asciidoc │ │ ├── 5fa5f7044a71ea73704e010bc0939d66.asciidoc │ │ ├── 80c693784ed2bd156bbc18e25b473c4b.asciidoc │ │ ├── d5dcddc6398b473b6ad9bce5c6adf986.asciidoc │ │ ├── 1af3365bc6ae4e76e3ea1665a130562a.asciidoc │ │ ├── 6f097c298a7abf4c032c4314920c49c8.asciidoc │ │ ├── 95b3f53f2065737bbeba6199e8a12df3.asciidoc │ │ ├── ac497917ef707538198a8458ae3d5c6b.asciidoc │ │ ├── 1284dcc6c5bee851d2e882fb6907537b.asciidoc │ │ ├── 1577e6e806b3283c9e99f1596d310754.asciidoc │ │ ├── 50631ca382018fdee1115b8ba507e594.asciidoc │ │ ├── b58dd0f65741d8d77b7a9bbbe7f0b385.asciidoc │ │ ├── 36962727b806315b221e8a63e05caddc.asciidoc │ │ ├── 68ef5e750e2ee895e6cad15cb75d7e8e.asciidoc │ │ ├── 9467e52087a13b63b02d78c35ff6f798.asciidoc │ │ ├── add240aa149d8b11139947502b279ee0.asciidoc │ │ ├── f2c3e3b90e5def84e508f7849a905ba6.asciidoc │ │ ├── dfb1fe96d806a644214d06f9b4b87878.asciidoc │ │ ├── 4339ba0872d8a9def4f80d7ebb2e560a.asciidoc │ │ ├── 6f9d516e7d0c8c0c8a4b0b9c732e720d.asciidoc │ │ ├── cd247f267968aa0927bfdad56852f8f5.asciidoc │ │ ├── 614a5520d02b015e33b86f85e38a5342.asciidoc │ │ ├── a72613de3774571ba24def4b495161b5.asciidoc │ │ ├── d7919fb6f4d02dde1390775eb8365b79.asciidoc │ │ ├── d7fe687201ac87b307cd06ed015dd317.asciidoc │ │ ├── e9c2e15b36372d5281c879d336322b6c.asciidoc │ │ ├── 231aa0bb39c35fe199d28fe0e4a62b2e.asciidoc │ │ ├── 23ab0f1023b1b2cd5cdf2a8f9ccfd57b.asciidoc │ │ ├── 5d6d4ab18a58ba42e9cdd86ed340d667.asciidoc │ │ ├── 820f689eaaef15fc07abd1073fa880f8.asciidoc │ │ ├── acc6cd860032167e34fa5e0c043ab3b0.asciidoc │ │ ├── c794d9a267fe04d29c7c273fc7f55261.asciidoc │ │ ├── cb01106bf524df5e0501d4c655c1aa7b.asciidoc │ │ ├── 1f2beb4f3177469243be16dff29d29ee.asciidoc │ │ ├── 4c3db8987d7b2d3d3df78ff1e71e7ede.asciidoc │ │ ├── 532ddf9afdcd0b1c9c0bb331e74d8df3.asciidoc │ │ ├── bd5918ab903c0889bb1f09c8c2466e43.asciidoc │ │ ├── eafdedb380e92f87aa6eca7cd839d0fb.asciidoc │ │ ├── edb4e2dcd529e1e74310cfa11a375917.asciidoc │ │ ├── 3bc872dbcdad8ff02cbaea39e7f38352.asciidoc │ │ ├── 44dfac5bc3131014e2c6bb1ebc76b33d.asciidoc │ │ ├── 69d5710bdec73041c66f21d5f96637e8.asciidoc │ │ ├── 6c37a80f652491ca525673b197e9ddcf.asciidoc │ │ ├── 734c2e2a1e45b84f1e4e65b51356fcd7.asciidoc │ │ ├── 978088f989d45dd09339582e9cbc60e0.asciidoc │ │ ├── a5f9eb40087921e67d820775acf71522.asciidoc │ │ ├── c32a3f8071d87f0a3f5a78e07fe7a669.asciidoc │ │ ├── 1216f8f7367df3aa823012cef310c08a.asciidoc │ │ ├── 378e55f78fa13578a1302bae8d479765.asciidoc │ │ ├── 52a87b81e4e0b6b11e23e85db1602a63.asciidoc │ │ ├── 803bbc14fbec0e49dfed9fab49c8a7f8.asciidoc │ │ ├── 9f04cc1a0c6cdb3ed2247f1399713767.asciidoc │ │ ├── dfcc83efefaddccfe5dce0695c2266ef.asciidoc │ │ ├── c1a895497066a3dac674d4b1a119048d.asciidoc │ │ ├── cda045dfd79acd160ed8668f2ee17ea7.asciidoc │ │ ├── e9dc1bd46146ce96910acc81fa649fc9.asciidoc │ │ ├── 3ae03ba3b56e5e287953094050766738.asciidoc │ │ ├── 3faf5e2873de340acfe0a617017db784.asciidoc │ │ ├── 764f9884b370cbdc82a1c5c42ed40ff3.asciidoc │ │ ├── beb0b9ff4f68672273fcff1b7bae706b.asciidoc │ │ ├── 34fac3da32d9acde04ca9b6da3d40edc.asciidoc │ │ ├── 2a9747bcfaf1f9491ebd410b3fcb6798.asciidoc │ │ ├── abd4fc3ce7784413a56fe2dcfe2809b5.asciidoc │ │ ├── b3a711c3deddcdb8a3f6623184a8b794.asciidoc │ │ ├── cdf400299acd1c7b1b7bb42e284e3d08.asciidoc │ │ ├── dfccd8ff46a6b44d2776951ea83e5a84.asciidoc │ │ ├── 0246f73cc2ed3dfec577119e8cd15404.asciidoc │ │ ├── 0c7b637b6b9f18c2149a9f9f51e3f09a.asciidoc │ │ ├── 20005d8a6555b259b299d862cd218701.asciidoc │ │ ├── 506844befdc5691d835771bcbb1c1a60.asciidoc │ │ ├── 54fb35cd129733591dab1e37165b7232.asciidoc │ │ ├── 6b77795e9249c8d9865f7a49fd86a863.asciidoc │ │ ├── 7ca224d1a7de20a15c008e1b9dbda377.asciidoc │ │ ├── 7e2e9f23daa324318b834bfaf67b798c.asciidoc │ │ ├── ea02de2dbe05091fcb0dac72c8ba5f83.asciidoc │ │ ├── f70a54cd9a9f4811bf962e469f2ca2ea.asciidoc │ │ ├── 2891aa10ee9d474780adf94d5607f2db.asciidoc │ │ ├── 6b0288acb739c4667d41339e5100c327.asciidoc │ │ ├── 78c96113ae4ed0054e581b17542528a7.asciidoc │ │ ├── ae563e7e5a445d0aa817cae7927b1c73.asciidoc │ │ ├── b6c872d04eabb39d1947cde6b29d4ae1.asciidoc │ │ ├── b708718eb368119fddb8f81381a17b28.asciidoc │ │ ├── 162b5b693b713f0bfab1209d59443c46.asciidoc │ │ ├── 41ad6077f9c1b8d8fefab6ea1660edcd.asciidoc │ │ ├── 5f1ed9cfdc149763b444acfbe10b0e16.asciidoc │ │ ├── 5f3549ac7fee94682ca0d7439eebdd2a.asciidoc │ │ ├── 8f9a3fcd17a111f63caa3bef6e5f00f2.asciidoc │ │ ├── b9370fa1aa18fe4bc00cf81ef0c0d45b.asciidoc │ │ ├── fad524db23eb5718ff310956e590b00d.asciidoc │ │ ├── 1aa91d3d48140d6367b6cabca8737b8f.asciidoc │ │ ├── 5b7d6f1db88ca6f42c48fa3dbb4341e8.asciidoc │ │ ├── a5a7050fb9dcb9574e081957ade28617.asciidoc │ │ ├── 2d150ff3b6b991b58fea6aa5cc669aa3.asciidoc │ │ ├── 6a1702dd50690cae833572e48a0ddf25.asciidoc │ │ ├── 7f56755fb6c42f7e6203339a6d0cb6e6.asciidoc │ │ ├── f092c643e308031484f0fc856afe2379.asciidoc │ │ ├── feefeb68144002fd1fff57b77b95b85e.asciidoc │ │ ├── 53b908c3432118c5a6e460f74d32006b.asciidoc │ │ ├── 934aa38c3adcc4cf74ea40cd8736876c.asciidoc │ │ ├── 957d2e6ddbb9a9b16549c5e67b93b41b.asciidoc │ │ ├── e821d27a8b810821707ba860e31f8b78.asciidoc │ │ ├── 2fd69fb0538e4f36ac69a8b8f8bf5ae8.asciidoc │ │ ├── 4acf902c2598b2558f34f20c1744c433.asciidoc │ │ ├── 8ad4a5ea7657eba25dc9a0ea994cf07d.asciidoc │ │ ├── e30ea6e3823a139d7693d8cce1920a06.asciidoc │ │ ├── f32f0c19b42de3b87dd764fe4ca17e7c.asciidoc │ │ ├── 5c2f486c27bd5346e512265f93375d16.asciidoc │ │ ├── a34d70d7022eb4ba48909d440c80390f.asciidoc │ │ ├── d3dccdb15822e971ededb9f6f7d8ada1.asciidoc │ │ ├── 20a36eb5a76396b7febf7b7166366f30.asciidoc │ │ ├── 472ec8c57fec8457e31fe6dd7f6e3713.asciidoc │ │ ├── 4b90feb9d5d3dbfce424dac0341320b7.asciidoc │ │ ├── 85479e02af00681210e17e3d0ff51e21.asciidoc │ │ ├── 2fea3e324939cc7e9c396964aeee7111.asciidoc │ │ ├── 54a215d242ab65123b09e9dfb71bcbbf.asciidoc │ │ ├── 9403764e6eccad7b321b65e9a10c5727.asciidoc │ │ ├── b607eea422295a3e9acd75f9ed1c8cb7.asciidoc │ │ ├── c5802e9f3f4068fcecb6937b867b270d.asciidoc │ │ ├── 0bcd380315ef4691b8c79df6ca53a85f.asciidoc │ │ ├── 436d50b85fc8f0977d02059eec00719b.asciidoc │ │ ├── e60ded7becfd5b2ccaef5bad2aaa93f5.asciidoc │ │ ├── 0d6ad80b5241552dd27af1a81c2eeb37.asciidoc │ │ ├── 1a803a6933babd15207499307cc325f8.asciidoc │ │ ├── 1bc731a4df952228af6dfa6b48627332.asciidoc │ │ ├── 53d61793dc11f2a8108a0b08875a637d.asciidoc │ │ ├── e7eca57a5bf5a53cbbe2463bce11495b.asciidoc │ │ ├── 0e118857b815b62118a30c042f079db1.asciidoc │ │ ├── 14701dcc0cca9665fce2aace0cb62af7.asciidoc │ │ ├── 68721288dc9ad8aa1b55099b4d303051.asciidoc │ │ ├── 6d5b9b693f2b59abd5aedcb5c8c9cec8.asciidoc │ │ ├── b91294751233d4d7e758400b9ea56fb5.asciidoc │ │ ├── 151d2b11807ec684b0c01aa89189a801.asciidoc │ │ ├── 8ecefdcf8f153cf91588e9fdde8f3e6b.asciidoc │ │ ├── a692b4c0ca7825c467880b346841f5a5.asciidoc │ │ ├── ba770c774af72e54b2b5a503b5332c71.asciidoc │ │ ├── fa88f6f5a7d728ec4f1d05244228cb09.asciidoc │ │ ├── 4955bae30f265b9e436f82b015de6d7e.asciidoc │ │ ├── ad2416ca0581316cee6c63129685bca5.asciidoc │ │ ├── bfdad8a928ea30d7cf60d0a0a6bc6e2e.asciidoc │ │ ├── eff2fc92d46eb3c8f4d424eed18f54a2.asciidoc │ │ ├── 64b9baa6d7556b960b29698f3383aa31.asciidoc │ │ ├── 8871b8fcb6de4f0c7dff22798fb10fb7.asciidoc │ │ ├── 8a1f6cffa653800282c0ae160ee375bc.asciidoc │ │ ├── 973a3ff47fc4ce036ecd9bd363fef9f7.asciidoc │ │ ├── ae9ccfaa146731ab9176df90670db1c2.asciidoc │ │ ├── ff1c66932f244050213f0c3cbcc214f9.asciidoc │ │ ├── 7fef68840761c6982c14ad7af96caf37.asciidoc │ │ ├── b94cee0f74f57742b3948f9b784dfdd4.asciidoc │ │ ├── ca51c02a2abd0f87c52448cd7b93a96d.asciidoc │ │ ├── 913770050ebbf3b9b549a899bc11060a.asciidoc │ │ ├── 5da6efd5b038ada64c9e853c88c1ec47.asciidoc │ │ ├── 047266b0d20fdb62ebc72d51952c8f6d.asciidoc │ │ ├── 4af6bd63a66b356748bed529ccbd1355.asciidoc │ │ ├── a7e58d4dc477a84c1306fd5749aafd8b.asciidoc │ │ ├── d8c857bbceed72c990038f1ef9d4f9e9.asciidoc │ │ ├── e270f3f721a5712cd11a5ca03554f5b0.asciidoc │ │ ├── 05d03b7be5fa4f34887044fccb75fbd0.asciidoc │ │ ├── 095d60b2cfc5004c97efc49f27287262.asciidoc │ │ ├── 7b908b1189f076942de8cd497ff1fa59.asciidoc │ │ ├── ad0dcbc7fc619e952c8825b8f307b7b2.asciidoc │ │ ├── f43d551aaaad73d979adf1b86533e6a3.asciidoc │ │ ├── 179f0a3e84ff4bbac18787a018eabf89.asciidoc │ │ ├── 25576b6773322f0929d4c635a940dba0.asciidoc │ │ ├── af44cc7fb0c435d4497c77baf904bf5e.asciidoc │ │ ├── afef5cac988592b97ae289ab39c2f437.asciidoc │ │ ├── f5815d573cee0447910c9668003887b8.asciidoc │ │ ├── 2615aaced23fbe827cbc00c364e4bd4f.asciidoc │ │ ├── 8552f4f3bfd69515b883ff43888a199b.asciidoc │ │ ├── 36b2778f23d0955255f52c075c4d213d.asciidoc │ │ ├── 5275842787967b6db876025f4a1c6942.asciidoc │ │ ├── 9beb260834f8cfb240f6308950dbb9c2.asciidoc │ │ ├── a22f1a6661a074a07041a710e4da6d50.asciidoc │ │ ├── f9fec6ec9a7da3d35ac674712bd5b813.asciidoc │ │ ├── 7f697eb436dfa3c30dfe610d8c32d132.asciidoc │ │ ├── e22ef762d6020157e3514d3cda16599c.asciidoc │ │ ├── 316cd43feb3b86396483903af1a048b1.asciidoc │ │ ├── 6ce0585ab13a480796add86de6b2037c.asciidoc │ │ ├── 9bfdda207b701028a3439e495e800c02.asciidoc │ │ ├── e6b972611c0ec8ab4c240f33f323d85b.asciidoc │ │ ├── 2533e4b36ae837eaecda08407ecb6383.asciidoc │ │ ├── 1da77e114459e0b77d78a3dcc8fae429.asciidoc │ │ ├── 4832108e01f5efac5e6e40ac405998ca.asciidoc │ │ ├── 25429a303a53d06fd0151f3618013ee4.asciidoc │ │ ├── 4342ccf6cc24fd80bd3cd1f9a4c2ef8e.asciidoc │ │ ├── 626f8c4b3e2cd3d9beaa63a7f5799d7a.asciidoc │ │ ├── aee4734ee63dbbbd12a21ee886f7a829.asciidoc │ │ ├── 251ea12c1248385ab409906ac64d9ee9.asciidoc │ │ ├── 3e573bfabe00f8bfb8bb69aa5820768e.asciidoc │ │ ├── 4c95d54b32df4dc49e9762b6c1ae2c05.asciidoc │ │ ├── acb10091ad335ddd15d71021aaf23c62.asciidoc │ │ ├── ecc57597f6b791d1151ad79d9f4ce67b.asciidoc │ │ ├── edae616e1244babf6032aecc6aaaf836.asciidoc │ │ ├── 52fd112e970882c4d7cc4b0cca8e2c6f.asciidoc │ │ ├── d88e3a006208680c0a1c6974e3acecbe.asciidoc │ │ ├── 3a6238835c7d9f51e6d91f92885fadeb.asciidoc │ │ ├── 929d8c007ba61644537af1441f038ea6.asciidoc │ │ ├── c4b278ba293abd0d02a0b5ad1a99f84a.asciidoc │ │ ├── 653c0d0ef146c997ef6bc6450d4f5f94.asciidoc │ │ ├── cfbaea6f0df045c5d940bbb6a9c69cd8.asciidoc │ │ ├── d2d30b766e42c74a38f73252a5edc36d.asciidoc │ │ ├── 5553cf7a02c22f616cd994747f2dd5a5.asciidoc │ │ ├── b0eaf67e5cce24ef8889bf20951ccec1.asciidoc │ │ ├── 33f148e3d8676de6cc52f58749898a13.asciidoc │ │ ├── 47bb632c6091ad0cd94bc660bdd309a5.asciidoc │ │ ├── 8eac28d2e9b6482b413d61817456a14f.asciidoc │ │ ├── 97babc8d19ef0866774576716eb6d19e.asciidoc │ │ ├── cd3986003382259348b84859f8ac2466.asciidoc │ │ ├── f495f9c99916a05e3b28166d31955fad.asciidoc │ │ ├── 37530f35f315b9f35e3e6a13cf2a1ccd.asciidoc │ │ ├── 5e0a6e903dcbef11da316fe89cf05792.asciidoc │ │ ├── 666c420fe61fa122386da3c356a64943.asciidoc │ │ ├── 9a4d5e41c52c20635d1fd9c6e13f6c7a.asciidoc │ │ └── ba0b4081c98f3387f76b77847c52ee9a.asciidoc ├── tab-widgets │ ├── delete-documents.asciidoc │ ├── delete-index.asciidoc │ ├── get-documents.asciidoc │ ├── create-index.asciidoc │ ├── update-documents.asciidoc │ └── connecting.asciidoc └── index.asciidoc ├── .codecov.yml ├── .ci ├── test-matrix.yml ├── jobs │ ├── elastic+go-elasticsearch+8.4.yml │ ├── elastic+go-elasticsearch+8.5.yml │ ├── elastic+go-elasticsearch+8.6.yml │ ├── elastic+go-elasticsearch+7.17.yml │ ├── elastic+go-elasticsearch+main.yml │ └── elastic+go-elasticsearch+pull-request.yml └── Dockerfile ├── .github └── workflows │ ├── license.yml │ └── backport.yml ├── go.mod ├── .buildkite ├── pipeline.yml └── Dockerfile └── catalog-info.yaml /.dockerignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | tmp/ 3 | -------------------------------------------------------------------------------- /_benchmarks/.gitignore: -------------------------------------------------------------------------------- 1 | go.sum 2 | tmp/ 3 | -------------------------------------------------------------------------------- /_examples/xkcdsearch/.dockerignore: -------------------------------------------------------------------------------- 1 | /tmp 2 | -------------------------------------------------------------------------------- /_examples/instrumentation/.dockerignore: -------------------------------------------------------------------------------- 1 | /tmp 2 | -------------------------------------------------------------------------------- /esapi/test/.gitignore: -------------------------------------------------------------------------------- 1 | go.sum 2 | *_test.go 3 | -------------------------------------------------------------------------------- /_examples/xkcdsearch/.gitignore: -------------------------------------------------------------------------------- 1 | /tmp 2 | /vendor 3 | -------------------------------------------------------------------------------- /_examples/bulk/.gitignore: -------------------------------------------------------------------------------- 1 | go.sum 2 | *_easyjson.go 3 | -------------------------------------------------------------------------------- /_examples/cloudfunction/.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | vendor/ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | *.test 3 | 4 | #jetBrains editors 5 | .idea 6 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Elasticsearch Go Client 2 | Copyright 2021 Elasticsearch B.V. -------------------------------------------------------------------------------- /_examples/encoding/.gitignore: -------------------------------------------------------------------------------- 1 | go.sum 2 | model/*_easyjson.go 3 | -------------------------------------------------------------------------------- /_examples/fasthttp/.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | vendor/ 3 | 4 | go.sum 5 | -------------------------------------------------------------------------------- /_examples/instrumentation/.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | vendor/ 3 | 4 | go.sum 5 | -------------------------------------------------------------------------------- /_examples/security/.gitignore: -------------------------------------------------------------------------------- 1 | go.sum 2 | 3 | certificates/ 4 | tmp/ 5 | -------------------------------------------------------------------------------- /internal/build/cmd/generate/commands/gentests/.gitignore: -------------------------------------------------------------------------------- 1 | api_registry.gen.go 2 | -------------------------------------------------------------------------------- /_examples/cloudfunction/.gcloudignore: -------------------------------------------------------------------------------- 1 | go.mod 2 | *_test.go 3 | *.png 4 | README* 5 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 303 See Other 2 | 3 | Location: https://www.elastic.co/community/codeofconduct -------------------------------------------------------------------------------- /.doc/images/es-endpoint.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/.doc/images/es-endpoint.jpg -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: off 2 | 3 | coverage: 4 | status: 5 | patch: off 6 | 7 | ignore: 8 | - "esapi/api.*.go" 9 | -------------------------------------------------------------------------------- /.doc/images/create-api-key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/.doc/images/create-api-key.png -------------------------------------------------------------------------------- /_benchmarks/scripts/run-benchmarks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -eo pipefail 4 | cd benchmarks && go run cmd/main.go 5 | -------------------------------------------------------------------------------- /_examples/encoding/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/encoding/screenshot.png -------------------------------------------------------------------------------- /_examples/security/.env: -------------------------------------------------------------------------------- 1 | COMPOSE_PROJECT_NAME='example' 2 | 3 | ELASTIC_VERSION=8.0.0-SNAPSHOT 4 | ELASTIC_PASSWORD=elastic 5 | -------------------------------------------------------------------------------- /_examples/bulk/kafka/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/bulk/kafka/screenshot.png -------------------------------------------------------------------------------- /_examples/xkcdsearch/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/xkcdsearch/screenshot.png -------------------------------------------------------------------------------- /_examples/cloudfunction/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/cloudfunction/screenshot.png -------------------------------------------------------------------------------- /_examples/instrumentation/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/instrumentation/screenshot.png -------------------------------------------------------------------------------- /_examples/xkcdsearch/web/assets/images/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/xkcdsearch/web/assets/images/left.png -------------------------------------------------------------------------------- /_examples/xkcdsearch/web/assets/images/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/xkcdsearch/web/assets/images/right.png -------------------------------------------------------------------------------- /_examples/xkcdsearch/web/assets/images/middle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/xkcdsearch/web/assets/images/middle.png -------------------------------------------------------------------------------- /.doc/typedapi/conventions/responses.asciidoc: -------------------------------------------------------------------------------- 1 | [[responses]] 2 | ==== Responses 3 | 4 | While not part of the initial release responses will be added at a later date. -------------------------------------------------------------------------------- /_examples/bulk/kafka/.env: -------------------------------------------------------------------------------- 1 | COMPOSE_PROJECT_NAME=kafka 2 | 3 | CONFLUENT_VERSION=5.4.0 4 | ELASTIC_VERSION=8.0.0-SNAPSHOT 5 | 6 | KAFKA_MEMORY=1G 7 | ES_MEMORY=1G 8 | -------------------------------------------------------------------------------- /_examples/xkcdsearch/web/assets/fonts/xkcd-script.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UlricQin/go-elasticsearch/main/_examples/xkcdsearch/web/assets/fonts/xkcd-script.woff -------------------------------------------------------------------------------- /.ci/test-matrix.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | STACK_VERSION: 4 | - 8.10.0-SNAPSHOT 5 | 6 | GO_VERSION: 7 | - 1-alpine 8 | 9 | TEST_SUITE: 10 | - free 11 | - platinum 12 | 13 | exclude: ~ 14 | -------------------------------------------------------------------------------- /internal/build/cmd/generate/commands/gentests/testdata/info/20_lucene_version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | "Lucene Version": 3 | - do: {info: {}} 4 | - is_true: version.lucene_version 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /_examples/bulk/benchmarks/data/small/document.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Test", 3 | "tags": [ 4 | "one", 5 | "two", 6 | "three" 7 | ], 8 | "count": 42, 9 | "time": "2020-02-20T08:59:42.000Z" 10 | } 11 | -------------------------------------------------------------------------------- /_examples/security/certificates-config.yml: -------------------------------------------------------------------------------- 1 | instances: 2 | - name: elasticsearch 3 | ip: [0.0.0.0, 127.0.0.1] 4 | dns: ["localhost", "example_elasticsearch_1", "example_elasticsearch_2", "example_elasticsearch_3"] 5 | -------------------------------------------------------------------------------- /.doc/examples/doc/b02e4907c9936c1adc16ccce9d49900d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from cluster-health_b02e4907c9936c1adc16ccce9d49900d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.Health() 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/3d1ff6097e2359f927c88c2ccdb36252.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from setup-install-check-running_3d1ff6097e2359f927c88c2ccdb36252_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Info() 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/1c23507edd7a3c18538b68223378e4ab.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-create-index_1c23507edd7a3c18538b68223378e4ab_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create("twitter") 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/12433d2b637d002e8d5c9a1adce69d3b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_12433d2b637d002e8d5c9a1adce69d3b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create("publications") 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/67bba546d835bca8f31df13e3587c348.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_67bba546d835bca8f31df13e3587c348_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get("test", "1", es.Get.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/be8f28f31207b173de61be032fcf239c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-get-index_be8f28f31207b173de61be032fcf239c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Get([]string{"twitter"}) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/cfc37446bd892d1ac42a3c8e8b204e6c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_cfc37446bd892d1ac42a3c8e8b204e6c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get("test2", "1", es.Get.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/f8cc4b331a19ff4df8e4a490f906ee69.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_f8cc4b331a19ff4df8e4a490f906ee69_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cat.Health(es.Cat.Health.WithV(true)) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/fbcf5078a6a9e09790553804054c36b3.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_fbcf5078a6a9e09790553804054c36b3_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get("twitter", "0", es.Get.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/3f3b3e207f79303ce6f86e03e928e062.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_3f3b3e207f79303ce6f86e03e928e062_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get("customer", "1", es.Get.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/98234499cfec70487cec5d013e976a84.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_98234499cfec70487cec5d013e976a84_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Exists("twitter", "_doc", es.Exists.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/98f14fddddea54a7d6149ab7b92e099d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-delete-index_98f14fddddea54a7d6149ab7b92e099d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Delete([]string{"twitter"}) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/c5e5873783246c7b1c01d8464fed72c4.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete_c5e5873783246c7b1c01d8464fed72c4_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Delete("twitter", "1", es.Delete.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /_examples/extension/Makefile: -------------------------------------------------------------------------------- 1 | GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test) 2 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 3 | 4 | test: ## Run tests 5 | go run main.go 6 | 7 | setup: 8 | 9 | .PHONY: test setup 10 | -------------------------------------------------------------------------------- /_examples/go.mod: -------------------------------------------------------------------------------- 1 | module _examples 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/elastic/elastic-transport-go/v8 v8.0.0-20211202110751-50105067ef27 // indirect 7 | github.com/elastic/go-elasticsearch/v8 v8.0.0-20211123103400-5f8a17a2322f // indirect 8 | ) 9 | -------------------------------------------------------------------------------- /.doc/examples/doc/89a8ac1509936acc272fc2d72907bc45.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_89a8ac1509936acc272fc2d72907bc45_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.GetSource("twitter", "1", es.GetSource.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/fabe14480624a99e8ee42c7338672058.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-create-index_fabe14480624a99e8ee42c7338672058_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create("test?wait_for_active_shards=2") 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /_examples/cloudfunction/Makefile: -------------------------------------------------------------------------------- 1 | GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test) 2 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 3 | 4 | test: ## Run tests 5 | $(GO_TEST_CMD) -v ./... 6 | 7 | setup: 8 | 9 | .PHONY: test setup 10 | -------------------------------------------------------------------------------- /_examples/xkcdsearch/Makefile: -------------------------------------------------------------------------------- 1 | GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test) 2 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 3 | 4 | test: ## Run tests 5 | $(GO_TEST_CMD) -v ./... 6 | 7 | setup: 8 | 9 | .PHONY: test setup 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/2468ab381257d759d8a88af1141f6f9c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_2468ab381257d759d8a88af1141f6f9c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.ExistsSource("twitter", "_source", es.ExistsSource.WithPretty()) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/a6fdd0100cd362df54af6c95d1055c96.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping_a6fdd0100cd362df54af6c95d1055c96_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.GetMapping(es.Indices.GetMapping.WithIndex("my-index-000001")) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/dea22bb4997e368950f0fc80f2a5f304.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping_dea22bb4997e368950f0fc80f2a5f304_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.GetMapping(es.Indices.GetMapping.WithIndex("my-index-000001")) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /_examples/logging/Makefile: -------------------------------------------------------------------------------- 1 | GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test) 2 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 3 | 4 | test: ## Run tests 5 | go run default.go 6 | go run custom.go 7 | 8 | setup: 9 | 10 | .PHONY: test setup 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/a8fba09a46b2c3524428aa3259b7124f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-get-mapping_a8fba09a46b2c3524428aa3259b7124f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.GetMapping(es.Indices.GetMapping.WithIndex("twitter")) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/cde4dddae5c06e7f1d38c9d933dbc7ac.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_cde4dddae5c06e7f1d38c9d933dbc7ac_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQuery( 6 | []string{"twitter,blog"}, 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/be3a6431d01846950dc1a39a7a6a1faa.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_be3a6431d01846950dc1a39a7a6a1faa_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Tasks.Get( 6 | "r1A2WoRbTwKZ516z6NEs5A:36619", 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /_examples/instrumentation/Makefile: -------------------------------------------------------------------------------- 1 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 2 | 3 | test: 4 | go build -o /dev/null expvar.go 5 | go build -o /dev/null opencensus.go 6 | go build -o /dev/null apmelasticsearch.go 7 | 8 | setup: 9 | 10 | .PHONY: test setup 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/c2c21e2824fbf6b7198ede30419da82b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_c2c21e2824fbf6b7198ede30419da82b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.ClearScroll( 6 | es.ClearScroll.WithScrollID("_all"), 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/cf02e3d8b371bd59f0224967c36330da.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-get-mapping_cf02e3d8b371bd59f0224967c36330da_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.GetMapping(es.Indices.GetMapping.WithIndex("twitter,kimchy")) 6 | fmt.Println(res, err) 7 | ---- 8 | -------------------------------------------------------------------------------- /.doc/examples/doc/68738b4fd0dda177022be45be95b4c84.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_68738b4fd0dda177022be45be95b4c84_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.ReindexRethrottle( 6 | "r1A2WoRbTwKZ516z6NEs5A:36619", 7 | esapi.IntPtr(-1), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/1dbb8cf17fbc45c87c7d2f75f15f9778.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_1dbb8cf17fbc45c87c7d2f75f15f9778_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.State( 6 | es.Cluster.State.WithFilterPath("metadata.indices.*.stat*"), 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/3e8ed6ae016eb823cb00d9035b8ac459.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-search_3e8ed6ae016eb823cb00d9035b8ac459_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithPretty(), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/4dac1d8953674f1640f2192a94dd1439.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-search_4dac1d8953674f1640f2192a94dd1439_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithQuery("user.id:kimchy"), 7 | es.Search.WithPretty(), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/621665fdbd7fc103c09bfeed28b67b1a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_621665fdbd7fc103c09bfeed28b67b1a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Count( 6 | es.Count.WithFilterPath("-_shards"), 7 | es.Count.WithPretty(), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/1252fa45847edba5ec2b2f33da70ec5b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_1252fa45847edba5ec2b2f33da70ec5b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.State( 6 | es.Cluster.State.WithFilterPath("routing_table.indices.**.state"), 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/138ccd89f72aa7502dd9578403dcc589.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_138ccd89f72aa7502dd9578403dcc589_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get( 6 | "twitter", 7 | "0", 8 | es.Get.WithSource("false"), 9 | es.Get.WithPretty(), 10 | ) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/18ddb7e7a4bcafd449df956e828ed7a8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_18ddb7e7a4bcafd449df956e828ed7a8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Tasks.Cancel( 6 | es.Tasks.Cancel.WithTaskID("r1A2WoRbTwKZ516z6NEs5A:36619"), 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/1d65cb6d055c46a1bde809687d835b71.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_1d65cb6d055c46a1bde809687d835b71_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get( 6 | "twitter", 7 | "2", 8 | es.Get.WithRouting("user1"), 9 | es.Get.WithPretty(), 10 | ) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/d8b115341da772a628a024e7d1644e73.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_d8b115341da772a628a024e7d1644e73_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQuery( 6 | []string{"twitter"}, 7 | es.UpdateByQuery.WithRouting("1"), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/52c7e4172a446c394210a07c464c57d2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_52c7e4172a446c394210a07c464c57d2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.DeleteByQueryRethrottle( 6 | "r1A2WoRbTwKZ516z6NEs5A:36619", 7 | esapi.IntPtr(-1), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/54a770f053f3225ea0d1e34334232411.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_54a770f053f3225ea0d1e34334232411_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQuery( 6 | []string{"twitter"}, 7 | es.UpdateByQuery.WithScrollSize(100), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/bdb30dd52d32f50994008f4f9c0da5f0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_bdb30dd52d32f50994008f4f9c0da5f0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQueryRethrottle( 6 | "r1A2WoRbTwKZ516z6NEs5A:36619", 7 | esapi.IntPtr(-1), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.github/workflows/license.yml: -------------------------------------------------------------------------------- 1 | name: License headers 2 | 3 | on: [ pull_request ] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - name: Check license headers 14 | run: | 15 | ./.github/check-license-headers.sh -------------------------------------------------------------------------------- /.doc/examples/doc/47b5ff897f26e9c943cee5c06034181d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete_47b5ff897f26e9c943cee5c06034181d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Delete("twitter", 6 | "1", 7 | es.Delete.WithRouting("kimchy"), 8 | es.Delete.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/745f9b8cdb8e91073f6e520e1d9f8c05.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_745f9b8cdb8e91073f6e520e1d9f8c05_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get( 6 | "twitter", 7 | "0", 8 | es.Get.WithSource("*.id,retweeted"), 9 | es.Get.WithPretty(), 10 | ) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/a4a396cd07657b3977713fb3a742c41b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_a4a396cd07657b3977713fb3a742c41b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQuery( 6 | []string{"twitter"}, 7 | es.UpdateByQuery.WithConflicts("proceed"), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/710c7871f20f176d51209b1574b0d61b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_710c7871f20f176d51209b1574b0d61b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get( 6 | "twitter", 7 | "1", 8 | es.Get.WithStoredFields("tags,counter"), 9 | es.Get.WithPretty(), 10 | ) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/7df191cc7f814e410a4ac7261065e6ef.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_7df191cc7f814e410a4ac7261065e6ef_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Tasks.List( 6 | es.Tasks.List.WithActions("*byquery"), 7 | es.Tasks.List.WithDetailed(true), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/1e18a67caf8f06ff2710ec4a8b30f625.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_1e18a67caf8f06ff2710ec4a8b30f625_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.State( 6 | es.Cluster.State.WithFilterPath("metadata.indices.*.state,-metadata.indices.logstash-*"), 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/216848930c2d344fe0bed0daa70c35b9.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_216848930c2d344fe0bed0daa70c35b9_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Tasks.List( 6 | es.Tasks.List.WithActions("*/delete/byquery"), 7 | es.Tasks.List.WithDetailed(true), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/4ca7f48438b7391e535ba0b76f7df148.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-search_4ca7f48438b7391e535ba0b76f7df148_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("*"), 7 | es.Search.WithQuery("user.id:kimchy"), 8 | es.Search.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/d90a84a24a407731dfc1929ac8327746.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete_d90a84a24a407731dfc1929ac8327746_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Delete("twitter", 6 | "1", 7 | es.Delete.WithTimeout(time.Duration(300000000000)), 8 | es.Delete.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/tab-widgets/delete-documents.asciidoc: -------------------------------------------------------------------------------- 1 | // tag::low-level[] 2 | 3 | [source,go] 4 | ---- 5 | client.Delete("my_index", "id") 6 | ---- 7 | 8 | // end::low-level[] 9 | 10 | 11 | // tag::fully-typed[] 12 | 13 | [source,go] 14 | ---- 15 | typedClient.Delete("my_index", "id").Do(context.TODO()) 16 | ---- 17 | 18 | // end::fully-typed[] -------------------------------------------------------------------------------- /.doc/typedapi/conventions/naming.asciidoc: -------------------------------------------------------------------------------- 1 | [[naming]] 2 | ==== Naming 3 | 4 | Whenever appropriate, names may be suffixed with an underscore: 5 | 6 | * To avoid collision with protected keywords (`range`, `if`, `type`, and so on). 7 | * To reflect the presence of a leading underscore in the API like `\_index` vs `Index_` or `\_source` vs `Source_`. -------------------------------------------------------------------------------- /.doc/examples/doc/1b542e3ea87a742f95641d64dcfb1bdb.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-count_1b542e3ea87a742f95641d64dcfb1bdb_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Count( 6 | es.Count.WithIndex("?q=user:kimchy"), 7 | es.Count.WithQuery("user:kimchy"), 8 | es.Count.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/8eb4376d4ff2587d0f14e63a7fb29a2a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-search_8eb4376d4ff2587d0f14e63a7fb29a2a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("_all"), 7 | es.Search.WithQuery("user.id:kimchy"), 8 | es.Search.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/c48264ec5d9b9679fddd72e5c44425b9.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from cluster-health_c48264ec5d9b9679fddd72e5c44425b9_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.Health( 6 | es.Cluster.Health.WithIndex([]string{"twitter"}...), 7 | es.Cluster.Health.WithLevel("shards"), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/tab-widgets/delete-index.asciidoc: -------------------------------------------------------------------------------- 1 | // tag::low-level[] 2 | 3 | [source,go] 4 | ---- 5 | client.Indices.Delete([]string{"my_index"}) 6 | ---- 7 | 8 | // end::low-level[] 9 | 10 | 11 | // tag::fully-typed[] 12 | 13 | [source,go] 14 | ---- 15 | typedClient.Indices.Delete("my_index").Do(context.TODO()) 16 | ---- 17 | 18 | // end::fully-typed[] -------------------------------------------------------------------------------- /esapi/test/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/elastic/go-elasticsearch/v8/esapi/test 2 | 3 | go 1.11 4 | 5 | replace github.com/elastic/go-elasticsearch/v8 => ../../ 6 | 7 | require ( 8 | github.com/elastic/elastic-transport-go/v8 v8.4.0 9 | github.com/elastic/go-elasticsearch/v8 v8.0.0-20210817150010-57d659deaca7 10 | gopkg.in/yaml.v2 v2.4.0 11 | ) 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/d2146e521344c5baa4984cf9147f18f2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-search_d2146e521344c5baa4984cf9147f18f2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithQuery("user.id:kimchy"), 8 | es.Search.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/04f5dd677c777bcb15d7d5fa63275fc8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from cluster-health_04f5dd677c777bcb15d7d5fa63275fc8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.Health( 6 | es.Cluster.Health.WithTimeout(time.Duration(50000000000)), 7 | es.Cluster.Health.WithWaitForStatus("yellow"), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/073539a7e38be3cdf13008330b6a536a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from cat-indices_073539a7e38be3cdf13008330b6a536a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cat.Indices( 6 | es.Cat.Indices.WithIndex([]string{"twi*"}...), 7 | es.Cat.Indices.WithS("index"), 8 | es.Cat.Indices.WithV(true), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/69a7be47f85138b10437113ab2f0d72d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_69a7be47f85138b10437113ab2f0d72d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get( 6 | "twitter", 7 | "2", 8 | es.Get.WithRouting("user1"), 9 | es.Get.WithStoredFields("tags,counter"), 10 | es.Get.WithPretty(), 11 | ) 12 | fmt.Println(res, err) 13 | ---- 14 | -------------------------------------------------------------------------------- /.doc/examples/doc/72beebe779a258c225dee7b023e60c52.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_72beebe779a258c225dee7b023e60c52_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Nodes.Stats( 6 | es.Nodes.Stats.WithMetric([]string{"indices"}...), 7 | es.Nodes.Stats.WithIndexMetric([]string{"search"}...), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/b9a153725b28fdd0a5aabd7f17a8c2d7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_b9a153725b28fdd0a5aabd7f17a8c2d7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.GetSettings( 6 | es.Indices.GetSettings.WithIndex([]string{"twitter"}...), 7 | es.Indices.GetSettings.WithFlatSettings(true), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/fe5763d32955e8b65eb3048e97b1580c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-update-settings_fe5763d32955e8b65eb3048e97b1580c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Forcemerge(es.Indices.Forcemerge.WithIndex([]string{"twitter"}...), 6 | es.Indices.Forcemerge.WithMaxNumSegments(5), 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/2749644d98cd9bbb0831f9281c311851.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-search_2749644d98cd9bbb0831f9281c311851_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001,my-index-000002"), 7 | es.Search.WithQuery("user.id:kimchy"), 8 | es.Search.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/3227b17f70d3cb3a5f2b296d6943848a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search_3227b17f70d3cb3a5f2b296d6943848a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.PutSettings( 6 | strings.NewReader(`{ 7 | "transient": { 8 | "cluster.routing.use_adaptive_replica_selection": false 9 | } 10 | }`)) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/5925c23a173a63bdb30b458248d1df76.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_5925c23a173a63bdb30b458248d1df76_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.GetSettings( 6 | es.Indices.GetSettings.WithIndex([]string{"twitter"}...), 7 | es.Indices.GetSettings.WithFlatSettings(false), 8 | ) 9 | fmt.Println(res, err) 10 | ---- 11 | -------------------------------------------------------------------------------- /.doc/examples/doc/8fdf2344c4fb3de6902ad7c5735270df.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_8fdf2344c4fb3de6902ad7c5735270df_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Get( 6 | "twitter", 7 | "0", 8 | es.Get.WithSourceExcludes("entities"), 9 | es.Get.WithSourceIncludes("*.id"), 10 | es.Get.WithPretty(), 11 | ) 12 | fmt.Println(res, err) 13 | ---- 14 | -------------------------------------------------------------------------------- /.github/workflows/backport.yml: -------------------------------------------------------------------------------- 1 | name: Backport 2 | on: 3 | pull_request: 4 | types: 5 | - closed 6 | - labeled 7 | 8 | jobs: 9 | backport: 10 | runs-on: ubuntu-latest 11 | name: Backport 12 | steps: 13 | - name: Backport 14 | uses: tibdex/backport@v1 15 | with: 16 | github_token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.doc/examples/doc/866f52fbe17d4177a9f0d49c422b95ff.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_866f52fbe17d4177a9f0d49c422b95ff_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "alias1", 7 | strings.NewReader(`{ 8 | "foo": "bar" 9 | }`), 10 | es.Index.WithDocumentID("1"), 11 | es.Index.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/8e6bfb4441ffa15c86d5dc20fa083571.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from setup-logging-config_8e6bfb4441ffa15c86d5dc20fa083571_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Cluster.PutSettings( 6 | strings.NewReader(`{ 7 | "transient": { 8 | "logger.org.elasticsearch.transport": "trace" 9 | } 10 | }`)) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/c22b72c4a52ee098331b3f252c22860d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_c22b72c4a52ee098331b3f252c22860d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.DeleteByQuery( 6 | []string{"twitter,blog"}, 7 | strings.NewReader(`{ 8 | "query": { 9 | "match_all": {} 10 | } 11 | }`), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/09dbd90c5e22ea4a17b4cf9aa72e08ae.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_09dbd90c5e22ea4a17b4cf9aa72e08ae_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithFilterPath("took,hits.hits._id,hits.hits._score"), 7 | es.Search.WithQuery("elasticsearch"), 8 | es.Search.WithPretty(), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/427f6b5c5376cbf0f71f242a60ca3d9e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_427f6b5c5376cbf0f71f242a60ca3d9e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("alias2"), 7 | es.Search.WithQuery("user:kimchy"), 8 | es.Search.WithRouting("2,3"), 9 | es.Search.WithPretty(), 10 | ) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/9bae72e974bdeb56007d9104e73eff92.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_9bae72e974bdeb56007d9104e73eff92_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "script": "ctx._source.remove('new_field')" 10 | }`), 11 | es.Update.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/a0f4e902d18460337684d74ea932fbe9.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_a0f4e902d18460337684d74ea932fbe9_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "doc": { 10 | "name": "new_name" 11 | } 12 | }`), 13 | es.Update.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/e567e6dbf86300142573c73789c8fce4.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_e567e6dbf86300142573c73789c8fce4_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("new_twitter"), 7 | es.Search.WithFilterPath("hits.total"), 8 | es.Search.WithSize(0), 9 | es.Search.WithPretty(), 10 | ) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/0cc991e3f7f8511a34730e154b3c5edc.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_0cc991e3f7f8511a34730e154b3c5edc_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "twitter" 9 | }, 10 | "dest": { 11 | "index": "new_twitter" 12 | } 13 | }`)) 14 | fmt.Println(res, err) 15 | ---- 16 | -------------------------------------------------------------------------------- /.doc/examples/doc/311c4b632a29b9ead63b02d01f10096b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_311c4b632a29b9ead63b02d01f10096b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "customer", 7 | strings.NewReader(`{ 8 | "name": "John Doe" 9 | }`), 10 | es.Index.WithDocumentID("1"), 11 | es.Index.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/bfcd65ab85d684d36a8550080032958d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-body_bfcd65ab85d684d36a8550080032958d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithQuery("message:number"), 7 | es.Search.WithSize(0), 8 | es.Search.WithTerminateAfter(1), 9 | es.Search.WithPretty(), 10 | ) 11 | fmt.Println(res, err) 12 | ---- 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/09d617863a103c82fb4101e6165ea7fe.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-all-query_09d617863a103c82fb4101e6165ea7fe_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match_all": {} 9 | } 10 | }`)), 11 | es.Search.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/53d938c754f36a912fcbe6473abb463f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_53d938c754f36a912fcbe6473abb463f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "users" 9 | }, 10 | "dest": { 11 | "index": "new_users" 12 | } 13 | }`)) 14 | fmt.Println(res, err) 15 | ---- 16 | -------------------------------------------------------------------------------- /.doc/examples/doc/6e000496a1fa8b57148518eaad692f35.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-all-query_6e000496a1fa8b57148518eaad692f35_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match_none": {} 9 | } 10 | }`)), 11 | es.Search.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/d222c6a6ec7a3beca6c97011b0874512.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_d222c6a6ec7a3beca6c97011b0874512_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.GetSource( 6 | "twitter", 7 | "1", 8 | es.GetSource.WithSourceExcludes("entities"), 9 | es.GetSource.WithSourceIncludes("*.id"), 10 | es.GetSource.WithPretty(), 11 | ) 12 | fmt.Println(res, err) 13 | ---- 14 | -------------------------------------------------------------------------------- /.doc/examples/doc/eb14cedd3bdda9ffef3c118f3d528dcd.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_eb14cedd3bdda9ffef3c118f3d528dcd_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "script": "ctx._source.new_field = 'value_of_new_field'" 10 | }`), 11 | es.Update.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/344b4144244d57f87c6aa4652b100b25.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-terms-query_344b4144244d57f87c6aa4652b100b25_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "my-index-000001", 7 | strings.NewReader(`{ 8 | "color": "blue" 9 | }`), 10 | es.Index.WithDocumentID("2"), 11 | es.Index.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /_examples/fasthttp/Makefile: -------------------------------------------------------------------------------- 1 | GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test) 2 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 3 | 4 | test: ## Run tests 5 | go run cmd/main.go 6 | 7 | bench: ## Run benchmarks 8 | $(GO_TEST_CMD) -run=none -bench=. -benchmem -benchtime=10s -v fasthttp_benchmark_test.go 9 | 10 | setup: 11 | 12 | .PHONY: test bench setup 13 | -------------------------------------------------------------------------------- /.doc/examples/doc/a69b1ce5cc9528fb3639185eaf241ae3.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_a69b1ce5cc9528fb3639185eaf241ae3_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.ClearScroll( 6 | es.ClearScroll.WithBody(strings.NewReader(`{ 7 | "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==" 8 | }`)), 9 | ) 10 | fmt.Println(res, err) 11 | ---- 12 | -------------------------------------------------------------------------------- /.doc/examples/doc/111c69ca94162c1523b799a5c14723dd.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-term-query_111c69ca94162c1523b799a5c14723dd_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "my-index-000001", 7 | strings.NewReader(`{ 8 | "full_text": "Quick Brown Foxes!" 9 | }`), 10 | es.Index.WithDocumentID("1"), 11 | es.Index.WithPretty(), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/41dbd79f624b998d01c10921e9a35c4b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_41dbd79f624b998d01c10921e9a35c4b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "doc": { 10 | "name": "new_name" 11 | }, 12 | "detect_noop": false 13 | }`), 14 | es.Update.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/52b2bfbdd78f8283b6f4891c48013237.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_52b2bfbdd78f8283b6f4891c48013237_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "max_docs": 1, 8 | "source": { 9 | "index": "twitter" 10 | }, 11 | "dest": { 12 | "index": "new_twitter" 13 | } 14 | }`)) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/339a47c843bd7ea9573bf8975918df2c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_339a47c843bd7ea9573bf8975918df2c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "counter": 1, 9 | "tags": [ 10 | "red" 11 | ] 12 | }`), 13 | es.Index.WithDocumentID("1"), 14 | es.Index.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/5be23858b35043fcb7b50fe36b873e6e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_5be23858b35043fcb7b50fe36b873e6e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"twitter"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "email": { 10 | "type": "keyword" 11 | } 12 | } 13 | }`), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/7b5c231526846f2f7b98d78f3656ae6a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_7b5c231526846f2f7b98d78f3656ae6a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "doc": { 10 | "name": "new_name" 11 | }, 12 | "doc_as_upsert": true 13 | }`), 14 | es.Update.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/b0fa301cd3c6b9db128e34114f0c1e8f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_b0fa301cd3c6b9db128e34114f0c1e8f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "test", 7 | strings.NewReader(`{ 8 | "counter": 1, 9 | "tags": [ 10 | "red" 11 | ] 12 | }`), 13 | es.Index.WithDocumentID("1"), 14 | es.Index.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/de876505acc75d371d1f6f484c449197.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-create-index_de876505acc75d371d1f6f484c449197_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "test", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "settings": { 9 | "index.write.wait_for_active_shards": "2" 10 | } 11 | }`)), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/e4be53736bcc02b03068fd72fdbfe271.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_e4be53736bcc02b03068fd72fdbfe271_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"publications"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "title": { 10 | "type": "text" 11 | } 12 | } 13 | }`), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/ebb6b59fbc9325c17e45f524602d6be2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_ebb6b59fbc9325c17e45f524602d6be2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.DeleteByQuery( 6 | []string{"twitter"}, 7 | strings.NewReader(`{ 8 | "query": { 9 | "match": { 10 | "message": "some message" 11 | } 12 | } 13 | }`), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/3b04cc894e6a47d57983484010feac0c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_3b04cc894e6a47d57983484010feac0c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Get("metricbeat-2016.05.30-1", "1", es.Get.WithPretty()) 7 | fmt.Println(res, err) 8 | } 9 | 10 | { 11 | res, err := es.Get("metricbeat-2016.05.31-1", "1", es.Get.WithPretty()) 12 | fmt.Println(res, err) 13 | } 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/d63033fcb0b13eb9476eb13f567c160a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-update-settings_d63033fcb0b13eb9476eb13f567c160a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutSettings(strings.NewReader(`{ 6 | "index": { 7 | "number_of_replicas": 2 8 | } 9 | }`), 10 | 11 | es.Indices.PutSettings.WithIndex([]string{"twitter"}...), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/e21e1c26dc8687e7bf7bd2bf019a6698.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_e21e1c26dc8687e7bf7bd2bf019a6698_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.DeleteByQuery( 6 | []string{"twitter"}, 7 | strings.NewReader(`{ 8 | "query": { 9 | "match_all": {} 10 | } 11 | }`), 12 | es.DeleteByQuery.WithConflicts("proceed"), 13 | ) 14 | fmt.Println(res, err) 15 | ---- 16 | -------------------------------------------------------------------------------- /.doc/examples/doc/025b54db0edc50c24ea48a2bd94366ad.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_025b54db0edc50c24ea48a2bd94366ad_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("twitter"), 7 | es.Search.WithFilterPath("hits.total"), 8 | es.Search.WithQuery("extra:test"), 9 | es.Search.WithSize(0), 10 | es.Search.WithPretty(), 11 | ) 12 | fmt.Println(res, err) 13 | ---- 14 | -------------------------------------------------------------------------------- /.doc/examples/doc/3d1a0e1dc5310544d032108ae0b3f099.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-all-query_3d1a0e1dc5310544d032108ae0b3f099_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match_all": { 9 | "boost": 1.2 10 | } 11 | } 12 | }`)), 13 | es.Search.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/3eddf4664660fccc9fb3102462009acb.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-update-settings_3eddf4664660fccc9fb3102462009acb_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutSettings(strings.NewReader(`{ 6 | "index": { 7 | "refresh_interval": "1s" 8 | } 9 | }`), 10 | 11 | es.Indices.PutSettings.WithIndex([]string{"twitter"}...), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/a05e022599d1789e90ff3a41469b0b6d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-update-settings_a05e022599d1789e90ff3a41469b0b6d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutSettings(strings.NewReader(`{ 6 | "index": { 7 | "refresh_interval": null 8 | } 9 | }`), 10 | 11 | es.Indices.PutSettings.WithIndex([]string{"twitter"}...), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/b1efa1c51a34dd5ab5511b71a399f5b1.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_b1efa1c51a34dd5ab5511b71a399f5b1_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "source" 9 | }, 10 | "dest": { 11 | "index": "dest", 12 | "pipeline": "some_ingest_pipeline" 13 | } 14 | }`)) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/e8cbe2269f3dff6b231e73119e81511d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-exists-query_e8cbe2269f3dff6b231e73119e81511d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "exists": { 9 | "field": "user" 10 | } 11 | } 12 | }`)), 13 | es.Search.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/f1fafd45a69147795642f974e37e7ad0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-update-settings_f1fafd45a69147795642f974e37e7ad0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutSettings(strings.NewReader(`{ 6 | "index": { 7 | "refresh_interval": "-1" 8 | } 9 | }`), 10 | 11 | es.Indices.PutSettings.WithIndex([]string{"twitter"}...), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/400e89eb46ead8e9c9e40f123fd5e590.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_400e89eb46ead8e9c9e40f123fd5e590_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "source", 9 | "size": 100 10 | }, 11 | "dest": { 12 | "index": "dest", 13 | "routing": "=cat" 14 | } 15 | }`)) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/5fa5f7044a71ea73704e010bc0939d66.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-index__5fa5f7044a71ea73704e010bc0939d66_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "user": "kimchy", 9 | "post_date": "2009-11-15T14:12:12", 10 | "message": "trying out Elasticsearch" 11 | }`), 12 | es.Index.WithPretty(), 13 | ) 14 | fmt.Println(res, err) 15 | ---- 16 | -------------------------------------------------------------------------------- /.doc/examples/doc/80c693784ed2bd156bbc18e25b473c4b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-create-index_80c693784ed2bd156bbc18e25b473c4b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "twitter", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "settings": { 9 | "number_of_shards": 3, 10 | "number_of_replicas": 2 11 | } 12 | }`)), 13 | ) 14 | fmt.Println(res, err) 15 | ---- 16 | -------------------------------------------------------------------------------- /.doc/examples/doc/d5dcddc6398b473b6ad9bce5c6adf986.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_d5dcddc6398b473b6ad9bce5c6adf986_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "sort": [ 8 | "_doc" 9 | ] 10 | }`)), 11 | es.Search.WithScroll(time.Duration(60000000000)), 12 | es.Search.WithPretty(), 13 | ) 14 | fmt.Println(res, err) 15 | ---- 16 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/elastic/go-elasticsearch/v8 2 | 3 | go 1.21 4 | 5 | require ( 6 | github.com/elastic/elastic-transport-go/v8 v8.5.0 7 | go.opentelemetry.io/otel/trace v1.21.0 8 | ) 9 | 10 | require ( 11 | github.com/go-logr/logr v1.3.0 // indirect 12 | github.com/go-logr/stdr v1.2.2 // indirect 13 | go.opentelemetry.io/otel v1.21.0 // indirect 14 | go.opentelemetry.io/otel/metric v1.21.0 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /.doc/examples/doc/1af3365bc6ae4e76e3ea1665a130562a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_1af3365bc6ae4e76e3ea1665a130562a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test1", 10 | "alias": "alias1" 11 | } 12 | } 13 | ] 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/6f097c298a7abf4c032c4314920c49c8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_6f097c298a7abf4c032c4314920c49c8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": [ 9 | "twitter", 10 | "blog" 11 | ] 12 | }, 13 | "dest": { 14 | "index": "all_together" 15 | } 16 | }`)) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/95b3f53f2065737bbeba6199e8a12df3.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-terms-query_95b3f53f2065737bbeba6199e8a12df3_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "my-index-000001", 7 | strings.NewReader(`{ 8 | "color": [ 9 | "blue", 10 | "green" 11 | ] 12 | }`), 13 | es.Index.WithDocumentID("1"), 14 | es.Index.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/ac497917ef707538198a8458ae3d5c6b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-query_ac497917ef707538198a8458ae3d5c6b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match": { 9 | "message": "this is a test" 10 | } 11 | } 12 | }`)), 13 | es.Search.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/1284dcc6c5bee851d2e882fb6907537b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search_1284dcc6c5bee851d2e882fb6907537b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match_all": {} 9 | }, 10 | "stats": [ 11 | "group1", 12 | "group2" 13 | ] 14 | }`)), 15 | es.Search.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/1577e6e806b3283c9e99f1596d310754.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_1577e6e806b3283c9e99f1596d310754_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "test", 7 | strings.NewReader(`{ 8 | "text": "words words", 9 | "flag": "foo" 10 | }`), 11 | es.Index.WithDocumentID("1"), 12 | es.Index.WithRefresh("true"), 13 | es.Index.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/50631ca382018fdee1115b8ba507e594.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_50631ca382018fdee1115b8ba507e594_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "twitter", 10 | "alias": "alias1" 11 | } 12 | } 13 | ] 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/b58dd0f65741d8d77b7a9bbbe7f0b385.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_b58dd0f65741d8d77b7a9bbbe7f0b385_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "remove": { 9 | "index": "test1", 10 | "alias": "alias1" 11 | } 12 | } 13 | ] 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/36962727b806315b221e8a63e05caddc.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping_36962727b806315b221e8a63e05caddc_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"my-index-000001"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "employee-id": { 10 | "type": "keyword", 11 | "index": false 12 | } 13 | } 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/68ef5e750e2ee895e6cad15cb75d7e8e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-index__68ef5e750e2ee895e6cad15cb75d7e8e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Create( 6 | "twitter", 7 | "1", 8 | strings.NewReader(`{ 9 | "user": "kimchy", 10 | "post_date": "2009-11-15T14:12:12", 11 | "message": "trying out Elasticsearch" 12 | }`), 13 | es.Create.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/9467e52087a13b63b02d78c35ff6f798.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-phrase-query_9467e52087a13b63b02d78c35ff6f798_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match_phrase": { 9 | "message": "this is a test" 10 | } 11 | } 12 | }`)), 13 | es.Search.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/add240aa149d8b11139947502b279ee0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_add240aa149d8b11139947502b279ee0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Scroll( 6 | es.Scroll.WithBody(strings.NewReader(`{ 7 | "scroll": "1m", 8 | "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==" 9 | }`)), 10 | es.Scroll.WithPretty(), 11 | ) 12 | fmt.Println(res, err) 13 | ---- 14 | -------------------------------------------------------------------------------- /.doc/examples/doc/f2c3e3b90e5def84e508f7849a905ba6.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_f2c3e3b90e5def84e508f7849a905ba6_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test*", 10 | "alias": "all_test_indices" 11 | } 12 | } 13 | ] 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/dfb1fe96d806a644214d06f9b4b87878.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_dfb1fe96d806a644214d06f9b4b87878_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.DeleteByQuery( 6 | []string{"twitter"}, 7 | strings.NewReader(`{ 8 | "query": { 9 | "term": { 10 | "user": "kimchy" 11 | } 12 | } 13 | }`), 14 | es.DeleteByQuery.WithScrollSize(5000), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/index.asciidoc: -------------------------------------------------------------------------------- 1 | = Elasticsearch Go Client 2 | 3 | :doctype: book 4 | 5 | include::{asciidoc-dir}/../../shared/versions/stack/{source_branch}.asciidoc[] 6 | 7 | include::{asciidoc-dir}/../../shared/attributes.asciidoc[] 8 | 9 | include::overview.asciidoc[] 10 | 11 | include::getting-started.asciidoc[] 12 | 13 | include::installation.asciidoc[] 14 | 15 | include::connecting.asciidoc[] 16 | 17 | include::typedapi/index.asciidoc[] -------------------------------------------------------------------------------- /_examples/bulk/benchmarks/data/small/mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "mappings": { 3 | "_meta": { 4 | "version": "8-SNAPSHOT" 5 | }, 6 | "properties": { 7 | "count": { 8 | "type": "long" 9 | }, 10 | "tags": { 11 | "type": "keyword" 12 | }, 13 | "time": { 14 | "type": "date" 15 | }, 16 | "title": { 17 | "type": "text" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/4339ba0872d8a9def4f80d7ebb2e560a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_4339ba0872d8a9def4f80d7ebb2e560a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "counter": 1, 9 | "tags": [ 10 | "white" 11 | ] 12 | }`), 13 | es.Index.WithDocumentID("2"), 14 | es.Index.WithRouting("user1"), 15 | es.Index.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/6f9d516e7d0c8c0c8a4b0b9c732e720d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-body_6f9d516e7d0c8c0c8a4b0b9c732e720d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("twitter"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "term": { 10 | "user": "kimchy" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/cd247f267968aa0927bfdad56852f8f5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_cd247f267968aa0927bfdad56852f8f5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match": { 10 | "address": "mill lane" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/614a5520d02b015e33b86f85e38a5342.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-search_614a5520d02b015e33b86f85e38a5342_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "term": { 10 | "user.id": "kimchy" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/a72613de3774571ba24def4b495161b5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_a72613de3774571ba24def4b495161b5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"my-index-000001"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "user_id": { 10 | "type": "alias", 11 | "path": "user_identifier" 12 | } 13 | } 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/d7919fb6f4d02dde1390775eb8365b79.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-params-fielddata_d7919fb6f4d02dde1390775eb8365b79_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"my-index-000001"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "my_field": { 10 | "type": "text", 11 | "fielddata": true 12 | } 13 | } 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/d7fe687201ac87b307cd06ed015dd317.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_d7fe687201ac87b307cd06ed015dd317_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"my-index-000001"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "user_id": { 10 | "type": "keyword", 11 | "ignore_above": 100 12 | } 13 | } 14 | }`), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/e9c2e15b36372d5281c879d336322b6c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_e9c2e15b36372d5281c879d336322b6c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "twitter", 9 | "_source": [ 10 | "user", 11 | "_doc" 12 | ] 13 | }, 14 | "dest": { 15 | "index": "new_twitter" 16 | } 17 | }`)) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/231aa0bb39c35fe199d28fe0e4a62b2e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_231aa0bb39c35fe199d28fe0e4a62b2e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match_phrase": { 10 | "address": "mill lane" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/23ab0f1023b1b2cd5cdf2a8f9ccfd57b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_23ab0f1023b1b2cd5cdf2a8f9ccfd57b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "test1", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "user": { 11 | "type": "keyword" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/5d6d4ab18a58ba42e9cdd86ed340d667.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_5d6d4ab18a58ba42e9cdd86ed340d667_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test", 10 | "alias": "alias1", 11 | "routing": "1" 12 | } 13 | } 14 | ] 15 | }`), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/820f689eaaef15fc07abd1073fa880f8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-from-size_820f689eaaef15fc07abd1073fa880f8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "from": 5, 8 | "size": 20, 9 | "query": { 10 | "match": { 11 | "user.id": "kimchy" 12 | } 13 | } 14 | }`)), 15 | es.Search.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/acc6cd860032167e34fa5e0c043ab3b0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_acc6cd860032167e34fa5e0c043ab3b0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "query": "city.\\*:(this AND that OR thus)" 10 | } 11 | } 12 | }`)), 13 | es.Search.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/c794d9a267fe04d29c7c273fc7f55261.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search_c794d9a267fe04d29c7c273fc7f55261_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "user": "kimchy", 9 | "post_date": "2009-11-15T14:12:12", 10 | "message": "trying out Elasticsearch" 11 | }`), 12 | es.Index.WithRouting("kimchy"), 13 | es.Index.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/cb01106bf524df5e0501d4c655c1aa7b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_cb01106bf524df5e0501d4c655c1aa7b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "twitter" 9 | }, 10 | "dest": { 11 | "index": "new_twitter" 12 | } 13 | }`), 14 | es.Reindex.WithRefresh(true), 15 | es.Reindex.WithSlices("5"), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /internal/build/cmd/generate/commands/gensource/testdata/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "stability": "stable", 4 | "documentation": { 5 | "url": "http://www.elastic.co/guide/", 6 | "description": "Returns basic information about the cluster." 7 | }, 8 | "url": { 9 | "paths": [ 10 | { 11 | "path": "/", 12 | "methods": ["GET"] 13 | } 14 | ] 15 | }, 16 | "params": {} 17 | } 18 | } -------------------------------------------------------------------------------- /.doc/examples/doc/1f2beb4f3177469243be16dff29d29ee.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-create-index_1f2beb4f3177469243be16dff29d29ee_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "twitter", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "settings": { 9 | "index": { 10 | "number_of_shards": 3, 11 | "number_of_replicas": 2 12 | } 13 | } 14 | }`)), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/4c3db8987d7b2d3d3df78ff1e71e7ede.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-query_4c3db8987d7b2d3d3df78ff1e71e7ede_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match": { 9 | "message": { 10 | "query": "this is a test" 11 | } 12 | } 13 | } 14 | }`)), 15 | es.Search.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/532ddf9afdcd0b1c9c0bb331e74d8df3.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_532ddf9afdcd0b1c9c0bb331e74d8df3_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "index_long", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "field": { 11 | "type": "long" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/bd5918ab903c0889bb1f09c8c2466e43.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_bd5918ab903c0889bb1f09c8c2466e43_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "users", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "user_id": { 11 | "type": "long" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/eafdedb380e92f87aa6eca7cd839d0fb.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-index__eafdedb380e92f87aa6eca7cd839d0fb_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "user": "kimchy", 9 | "post_date": "2009-11-15T14:12:12", 10 | "message": "trying out Elasticsearch" 11 | }`), 12 | es.Index.WithDocumentID("1"), 13 | es.Index.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/edb4e2dcd529e1e74310cfa11a375917.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-index__edb4e2dcd529e1e74310cfa11a375917_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "user": "kimchy", 9 | "post_date": "2009-11-15T14:12:12", 10 | "message": "trying out Elasticsearch" 11 | }`), 12 | es.Index.WithRouting("kimchy"), 13 | es.Index.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/3bc872dbcdad8ff02cbaea39e7f38352.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_3bc872dbcdad8ff02cbaea39e7f38352_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "index_double", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "field": { 11 | "type": "date" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/44dfac5bc3131014e2c6bb1ebc76b33d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_44dfac5bc3131014e2c6bb1ebc76b33d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "index_double", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "field": { 11 | "type": "double" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/69d5710bdec73041c66f21d5f96637e8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_69d5710bdec73041c66f21d5f96637e8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "index_long", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "field": { 11 | "type": "date_nanos" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/6c37a80f652491ca525673b197e9ddcf.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_6c37a80f652491ca525673b197e9ddcf_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "field": "genre" 11 | } 12 | } 13 | } 14 | }`)), 15 | es.Search.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/734c2e2a1e45b84f1e4e65b51356fcd7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_734c2e2a1e45b84f1e4e65b51356fcd7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "new_users", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "user_id": { 11 | "type": "keyword" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/978088f989d45dd09339582e9cbc60e0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_978088f989d45dd09339582e9cbc60e0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("%3Clogstash-%7Bnow%2Fd%7D%3E"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match": { 10 | "test": "data" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/a5f9eb40087921e67d820775acf71522.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_a5f9eb40087921e67d820775acf71522_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "city": { 11 | "type": "text" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/c32a3f8071d87f0a3f5a78e07fe7a669.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_c32a3f8071d87f0a3f5a78e07fe7a669_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.DeleteByQuery( 6 | []string{"twitter"}, 7 | strings.NewReader(`{ 8 | "query": { 9 | "range": { 10 | "age": { 11 | "gte": 10 12 | } 13 | } 14 | } 15 | }`), 16 | es.DeleteByQuery.WithRouting("1"), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/1216f8f7367df3aa823012cef310c08a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_1216f8f7367df3aa823012cef310c08a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "test" 9 | }, 10 | "dest": { 11 | "index": "test2" 12 | }, 13 | "script": { 14 | "source": "ctx._source.tag = ctx._source.remove(\"flag\")" 15 | } 16 | }`)) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/378e55f78fa13578a1302bae8d479765.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-terms-query_378e55f78fa13578a1302bae8d479765_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "color": { 11 | "type": "keyword" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/52a87b81e4e0b6b11e23e85db1602a63.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_52a87b81e4e0b6b11e23e85db1602a63_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQuery( 6 | []string{"twitter"}, 7 | es.UpdateByQuery.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "term": { 10 | "user": "kimchy" 11 | } 12 | } 13 | }`)), 14 | es.UpdateByQuery.WithConflicts("proceed"), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/803bbc14fbec0e49dfed9fab49c8a7f8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-term-query_803bbc14fbec0e49dfed9fab49c8a7f8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "full_text": { 11 | "type": "text" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/9f04cc1a0c6cdb3ed2247f1399713767.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-types-keyword_9f04cc1a0c6cdb3ed2247f1399713767_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "tags": { 11 | "type": "keyword" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/dfcc83efefaddccfe5dce0695c2266ef.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-nested-query_dfcc83efefaddccfe5dce0695c2266ef_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "obj1": { 11 | "type": "nested" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/c1a895497066a3dac674d4b1a119048d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-term-query_c1a895497066a3dac674d4b1a119048d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "term": { 10 | "full_text": "Quick Brown Foxes!" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/cda045dfd79acd160ed8668f2ee17ea7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-term-query_cda045dfd79acd160ed8668f2ee17ea7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match": { 10 | "full_text": "Quick Brown Foxes!" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/e9dc1bd46146ce96910acc81fa649fc9.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-term-query_e9dc1bd46146ce96910acc81fa649fc9_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "term": { 9 | "user": { 10 | "value": "Kimchy", 11 | "boost": 1.0 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/typedapi/conventions/index.asciidoc: -------------------------------------------------------------------------------- 1 | [[conventions]] 2 | === Conventions 3 | 4 | This section details the conventions upon which the typed client is built. 5 | 6 | * <> 7 | * <> 8 | * <> 9 | * <> 10 | * <> 11 | * <> 12 | 13 | include::structure.asciidoc[] 14 | include::naming.asciidoc[] 15 | include::endpoints.asciidoc[] 16 | include::requests.asciidoc[] 17 | include::responses.asciidoc[] 18 | include::types.asciidoc[] -------------------------------------------------------------------------------- /.doc/examples/doc/3ae03ba3b56e5e287953094050766738.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_3ae03ba3b56e5e287953094050766738_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Indices.Refresh() 7 | fmt.Println(res, err) 8 | } 9 | 10 | { 11 | res, err := es.Search( 12 | es.Search.WithIndex("new_twitter"), 13 | es.Search.WithFilterPath("hits.total"), 14 | es.Search.WithSize(0), 15 | es.Search.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | } 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/3faf5e2873de340acfe0a617017db784.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_3faf5e2873de340acfe0a617017db784_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "query": "(content:this OR name:this) AND (content:that OR name:that)" 10 | } 11 | } 12 | }`)), 13 | es.Search.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/764f9884b370cbdc82a1c5c42ed40ff3.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_764f9884b370cbdc82a1c5c42ed40ff3_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "twitter", 9 | "query": { 10 | "term": { 11 | "user": "kimchy" 12 | } 13 | } 14 | }, 15 | "dest": { 16 | "index": "new_twitter" 17 | } 18 | }`)) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/beb0b9ff4f68672273fcff1b7bae706b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_beb0b9ff4f68672273fcff1b7bae706b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "user_identifier": { 11 | "type": "keyword" 12 | } 13 | } 14 | } 15 | }`)), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/tab-widgets/get-documents.asciidoc: -------------------------------------------------------------------------------- 1 | // tag::low-level[] 2 | 3 | You can get documents by using the following code with the low-level API: 4 | 5 | [source,go] 6 | ---- 7 | client.Get("my_index", "id") 8 | ---- 9 | 10 | // end::low-level[] 11 | 12 | 13 | // tag::fully-typed[] 14 | 15 | This is how you can get documents by using the fully-typed API: 16 | 17 | [source,go] 18 | ---- 19 | typedClient.Get("my_index", "id").Do(context.TODO()) 20 | ---- 21 | 22 | // end::fully-typed[] -------------------------------------------------------------------------------- /.doc/examples/doc/34fac3da32d9acde04ca9b6da3d40edc.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-range-query_34fac3da32d9acde04ca9b6da3d40edc_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "range": { 9 | "timestamp": { 10 | "gte": "now-1d/d", 11 | "lt": "now/d" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/2a9747bcfaf1f9491ebd410b3fcb6798.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_2a9747bcfaf1f9491ebd410b3fcb6798_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "query": "(new york city) OR (big apple)", 10 | "default_field": "content" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/abd4fc3ce7784413a56fe2dcfe2809b5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_abd4fc3ce7784413a56fe2dcfe2809b5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("test"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match": { 10 | "flag": "foo" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithFilterPath("hits.total"), 15 | es.Search.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/b3a711c3deddcdb8a3f6623184a8b794.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_b3a711c3deddcdb8a3f6623184a8b794_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "script": { 10 | "source": "ctx._source.counter += params.count", 11 | "lang": "painless", 12 | "params": { 13 | "count": 4 14 | } 15 | } 16 | }`), 17 | es.Update.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/cdf400299acd1c7b1b7bb42e284e3d08.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_cdf400299acd1c7b1b7bb42e284e3d08_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "script": { 10 | "source": "ctx._source.tags.add(params.tag)", 11 | "lang": "painless", 12 | "params": { 13 | "tag": "blue" 14 | } 15 | } 16 | }`), 17 | es.Update.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/dfccd8ff46a6b44d2776951ea83e5a84.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_dfccd8ff46a6b44d2776951ea83e5a84_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "indices": [ 10 | "test1", 11 | "test2" 12 | ], 13 | "alias": "alias1" 14 | } 15 | } 16 | ] 17 | }`), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/tab-widgets/create-index.asciidoc: -------------------------------------------------------------------------------- 1 | // tag::low-level[] 2 | 3 | This is how you create the `my_index` index with the low level API: 4 | 5 | [source,go] 6 | ---- 7 | client.Indices.Create("my_index") 8 | ---- 9 | 10 | // end::low-level[] 11 | 12 | 13 | // tag::fully-typed[] 14 | 15 | This is how you create the `my_index` index with the fully-typed API: 16 | 17 | [source,go] 18 | ---- 19 | typedClient.Indices.Create("my_index").Do(context.TODO()) 20 | ---- 21 | 22 | // end::fully-typed[] -------------------------------------------------------------------------------- /.doc/examples/doc/0246f73cc2ed3dfec577119e8cd15404.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_0246f73cc2ed3dfec577119e8cd15404_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"my-index-000001"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "name": { 10 | "properties": { 11 | "last": { 12 | "type": "text" 13 | } 14 | } 15 | } 16 | } 17 | }`), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/0c7b637b6b9f18c2149a9f9f51e3f09a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-exists-query_0c7b637b6b9f18c2149a9f9f51e3f09a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "bool": { 9 | "must_not": { 10 | "exists": { 11 | "field": "user" 12 | } 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/20005d8a6555b259b299d862cd218701.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-query_20005d8a6555b259b299d862cd218701_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match": { 9 | "message": { 10 | "query": "this is a test", 11 | "operator": "and" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/506844befdc5691d835771bcbb1c1a60.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_506844befdc5691d835771bcbb1c1a60_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match_all": {} 10 | }, 11 | "sort": [ 12 | { 13 | "account_number": "asc" 14 | } 15 | ] 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/54fb35cd129733591dab1e37165b7232.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-index__54fb35cd129733591dab1e37165b7232_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "message": "elasticsearch now has versioning support, double cool!" 9 | }`), 10 | es.Index.WithDocumentID("1"), 11 | es.Index.WithVersion(2), 12 | es.Index.WithVersionType("external"), 13 | es.Index.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/6b77795e9249c8d9865f7a49fd86a863.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-range-query_6b77795e9249c8d9865f7a49fd86a863_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "range": { 9 | "age": { 10 | "gte": 10, 11 | "lte": 20, 12 | "boost": 2.0 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/7ca224d1a7de20a15c008e1b9dbda377.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_7ca224d1a7de20a15c008e1b9dbda377_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "tags": { 9 | "terms": { 10 | "field": "tags", 11 | "missing": "N/A" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/7e2e9f23daa324318b834bfaf67b798c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-index__7e2e9f23daa324318b834bfaf67b798c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "user": "kimchy", 9 | "post_date": "2009-11-15T14:12:12", 10 | "message": "trying out Elasticsearch" 11 | }`), 12 | es.Index.WithDocumentID("1"), 13 | es.Index.WithOpType("create"), 14 | es.Index.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/ea02de2dbe05091fcb0dac72c8ba5f83.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_ea02de2dbe05091fcb0dac72c8ba5f83_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQuery( 6 | []string{"twitter"}, 7 | es.UpdateByQuery.WithBody(strings.NewReader(`{ 8 | "script": { 9 | "source": "ctx._source['extra'] = 'test'" 10 | } 11 | }`)), 12 | es.UpdateByQuery.WithRefresh(true), 13 | es.UpdateByQuery.WithSlices("5"), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/f70a54cd9a9f4811bf962e469f2ca2ea.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-bool-query_f70a54cd9a9f4811bf962e469f2ca2ea_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "bool": { 9 | "filter": { 10 | "term": { 11 | "status": "active" 12 | } 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.ci/jobs/elastic+go-elasticsearch+8.4.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - job: 3 | name: elastic+go-elasticsearch+8.4 4 | display-name: 'elastic / go-elasticsearch # 8.4' 5 | description: Testing the go-elasticsearch 8.4 branch. 6 | junit_results: "*-junit.xml" 7 | parameters: 8 | - string: 9 | name: branch_specifier 10 | default: refs/heads/8.4 11 | description: The Git branch specifier to build 12 | triggers: 13 | - github 14 | - timed: 'H */12 * * *' 15 | -------------------------------------------------------------------------------- /.ci/jobs/elastic+go-elasticsearch+8.5.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - job: 3 | name: elastic+go-elasticsearch+8.5 4 | display-name: 'elastic / go-elasticsearch # 8.5' 5 | description: Testing the go-elasticsearch 8.5 branch. 6 | junit_results: "*-junit.xml" 7 | parameters: 8 | - string: 9 | name: branch_specifier 10 | default: refs/heads/8.5 11 | description: The Git branch specifier to build 12 | triggers: 13 | - github 14 | - timed: 'H */12 * * *' 15 | -------------------------------------------------------------------------------- /.ci/jobs/elastic+go-elasticsearch+8.6.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - job: 3 | name: elastic+go-elasticsearch+8.6 4 | display-name: 'elastic / go-elasticsearch # 8.6' 5 | description: Testing the go-elasticsearch 8.6 branch. 6 | junit_results: "*-junit.xml" 7 | parameters: 8 | - string: 9 | name: branch_specifier 10 | default: refs/heads/8.6 11 | description: The Git branch specifier to build 12 | triggers: 13 | - github 14 | - timed: 'H */12 * * *' 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/2891aa10ee9d474780adf94d5607f2db.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_2891aa10ee9d474780adf94d5607f2db_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("index_long,index_double"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "sort": [ 9 | { 10 | "field": { 11 | "numeric_type": "double" 12 | } 13 | } 14 | ] 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/6b0288acb739c4667d41339e5100c327.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-query_6b0288acb739c4667d41339e5100c327_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match": { 9 | "message": { 10 | "query": "this is a testt", 11 | "fuzziness": "AUTO" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/78c96113ae4ed0054e581b17542528a7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_78c96113ae4ed0054e581b17542528a7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "source", 9 | "query": { 10 | "match": { 11 | "company": "cat" 12 | } 13 | } 14 | }, 15 | "dest": { 16 | "index": "dest", 17 | "routing": "=cat" 18 | } 19 | }`)) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/ae563e7e5a445d0aa817cae7927b1c73.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-terms-query_ae563e7e5a445d0aa817cae7927b1c73_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "terms": { 9 | "user": [ 10 | "kimchy", 11 | "elasticsearch" 12 | ], 13 | "boost": 1.0 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/b6c872d04eabb39d1947cde6b29d4ae1.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_b6c872d04eabb39d1947cde6b29d4ae1_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "tags": { 9 | "terms": { 10 | "field": "tags", 11 | "min_doc_count": 10 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/b708718eb368119fddb8f81381a17b28.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_b708718eb368119fddb8f81381a17b28_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test", 10 | "alias": "alias2", 11 | "search_routing": "1,2", 12 | "index_routing": "2" 13 | } 14 | } 15 | ] 16 | }`), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.ci/jobs/elastic+go-elasticsearch+7.17.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - job: 3 | name: elastic+go-elasticsearch+7.17 4 | display-name: 'elastic / go-elasticsearch # 7.17' 5 | description: Testing the go-elasticsearch 7.17 branch. 6 | junit_results: "*-junit.xml" 7 | parameters: 8 | - string: 9 | name: branch_specifier 10 | default: refs/heads/7.17 11 | description: The Git branch specifier to build 12 | triggers: 13 | - github 14 | - timed: 'H */12 * * *' 15 | -------------------------------------------------------------------------------- /.ci/jobs/elastic+go-elasticsearch+main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - job: 3 | name: elastic+go-elasticsearch+main 4 | display-name: 'elastic / go-elasticsearch # main' 5 | description: Testing the go-elasticsearch main branch. 6 | junit_results: "*-junit.xml" 7 | parameters: 8 | - string: 9 | name: branch_specifier 10 | default: refs/heads/main 11 | description: The Git branch specifier to build 12 | triggers: 13 | - github 14 | - timed: 'H */12 * * *' 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/162b5b693b713f0bfab1209d59443c46.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-bool-query_162b5b693b713f0bfab1209d59443c46_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "constant_score": { 9 | "filter": { 10 | "term": { 11 | "status": "active" 12 | } 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/41ad6077f9c1b8d8fefab6ea1660edcd.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-params-format_41ad6077f9c1b8d8fefab6ea1660edcd_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "date": { 11 | "type": "date", 12 | "format": "yyyy-MM-dd" 13 | } 14 | } 15 | } 16 | }`)), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/5f1ed9cfdc149763b444acfbe10b0e16.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_5f1ed9cfdc149763b444acfbe10b0e16_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "user_id": { 11 | "type": "keyword", 12 | "ignore_above": 20 13 | } 14 | } 15 | } 16 | }`)), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/5f3549ac7fee94682ca0d7439eebdd2a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_5f3549ac7fee94682ca0d7439eebdd2a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("index_long,index_double"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "sort": [ 9 | { 10 | "field": { 11 | "numeric_type": "date_nanos" 12 | } 13 | } 14 | ] 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/8f9a3fcd17a111f63caa3bef6e5f00f2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_8f9a3fcd17a111f63caa3bef6e5f00f2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "tags": { 9 | "terms": { 10 | "field": "tags", 11 | "execution_hint": "map" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/b9370fa1aa18fe4bc00cf81ef0c0d45b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_b9370fa1aa18fe4bc00cf81ef0c0d45b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "city.*" 11 | ], 12 | "query": "this AND that OR thus" 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/fad524db23eb5718ff310956e590b00d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-function-score-query_fad524db23eb5718ff310956e590b00d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "function_score": { 9 | "random_score": { 10 | "seed": 10, 11 | "field": "_seq_no" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/1aa91d3d48140d6367b6cabca8737b8f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-bulk_1aa91d3d48140d6367b6cabca8737b8f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Bulk( 6 | strings.NewReader(` 7 | { "update": {"_id": "5", "_index": "index1"} } 8 | { "doc": {"my_field": "foo"} } 9 | { "update": {"_id": "6", "_index": "index1"} } 10 | { "doc": {"my_field": "foo"} } 11 | { "create": {"_id": "7", "_index": "index1"} } 12 | { "my_field": "foo" } 13 | `), 14 | ) 15 | fmt.Println(res, err) 16 | ---- 17 | -------------------------------------------------------------------------------- /.doc/examples/doc/5b7d6f1db88ca6f42c48fa3dbb4341e8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-get-mapping_5b7d6f1db88ca6f42c48fa3dbb4341e8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Indices.GetMapping(es.Indices.GetMapping.WithIndex("*")) 7 | fmt.Println(res, err) 8 | } 9 | 10 | { 11 | res, err := es.Indices.GetMapping(es.Indices.GetMapping.WithIndex("_all")) 12 | fmt.Println(res, err) 13 | } 14 | 15 | { 16 | res, err := es.Indices.GetMapping() 17 | fmt.Println(res, err) 18 | } 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/a5a7050fb9dcb9574e081957ade28617.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_a5a7050fb9dcb9574e081957ade28617_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.DeleteByQuery( 6 | []string{"twitter"}, 7 | strings.NewReader(`{ 8 | "query": { 9 | "range": { 10 | "likes": { 11 | "lt": 10 12 | } 13 | } 14 | } 15 | }`), 16 | es.DeleteByQuery.WithRefresh(true), 17 | es.DeleteByQuery.WithSlices("5"), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/2d150ff3b6b991b58fea6aa5cc669aa3.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-phrase-query_2d150ff3b6b991b58fea6aa5cc669aa3_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match_phrase": { 9 | "message": { 10 | "query": "this is a test", 11 | "analyzer": "my_analyzer" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/6a1702dd50690cae833572e48a0ddf25.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_6a1702dd50690cae833572e48a0ddf25_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "Will Smith", 10 | "fields": [ 11 | "title", 12 | "*_name" 13 | ] 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/7f56755fb6c42f7e6203339a6d0cb6e6.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-query_7f56755fb6c42f7e6203339a6d0cb6e6_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match": { 9 | "message": { 10 | "query": "ny city", 11 | "auto_generate_synonyms_phrase_query": false 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/f092c643e308031484f0fc856afe2379.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-index__f092c643e308031484f0fc856afe2379_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "twitter", 7 | strings.NewReader(`{ 8 | "user": "kimchy", 9 | "post_date": "2009-11-15T14:12:12", 10 | "message": "trying out Elasticsearch" 11 | }`), 12 | es.Index.WithDocumentID("1"), 13 | es.Index.WithTimeout(time.Duration(300000000000)), 14 | es.Index.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/feefeb68144002fd1fff57b77b95b85e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_feefeb68144002fd1fff57b77b95b85e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "size": 0, 9 | "aggs": { 10 | "group_by_state": { 11 | "terms": { 12 | "field": "state.keyword" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/53b908c3432118c5a6e460f74d32006b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_53b908c3432118c5a6e460f74d32006b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "this is a test", 10 | "fields": [ 11 | "subject", 12 | "message" 13 | ] 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/934aa38c3adcc4cf74ea40cd8736876c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-create-index_934aa38c3adcc4cf74ea40cd8736876c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "test", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "settings": { 9 | "number_of_shards": 1 10 | }, 11 | "mappings": { 12 | "properties": { 13 | "field1": { 14 | "type": "text" 15 | } 16 | } 17 | } 18 | }`)), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/957d2e6ddbb9a9b16549c5e67b93b41b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_957d2e6ddbb9a9b16549c5e67b93b41b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "content", 11 | "name" 12 | ], 13 | "query": "this AND that" 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/e821d27a8b810821707ba860e31f8b78.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_e821d27a8b810821707ba860e31f8b78_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.PutMapping( 6 | []string{"my-index-000001"}, 7 | strings.NewReader(`{ 8 | "properties": { 9 | "city": { 10 | "type": "text", 11 | "fields": { 12 | "raw": { 13 | "type": "keyword" 14 | } 15 | } 16 | } 17 | } 18 | }`), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /_benchmarks/benchmarks/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/elastic/go-elasticsearch/v8/benchmarks 2 | 3 | go 1.14 4 | 5 | replace github.com/elastic/go-elasticsearch/v8 => ../../ 6 | 7 | require ( 8 | github.com/elastic/elastic-transport-go/v8 v8.0.0-20211216131617-bbee439d559c 9 | github.com/elastic/go-elasticsearch/v8 v8.0.0-20200408073057-6f36a473b19f 10 | github.com/fatih/color v1.7.0 11 | github.com/mattn/go-colorable v0.1.6 // indirect 12 | github.com/montanaflynn/stats v0.6.3 13 | github.com/tidwall/gjson v1.9.3 14 | ) 15 | -------------------------------------------------------------------------------- /_examples/encoding/Makefile: -------------------------------------------------------------------------------- 1 | GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test) 2 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 3 | 4 | test: clean setup ## Run tests 5 | go run gjson.go 6 | go generate ./model && go run easyjson.go 7 | go run jsonreader.go 8 | 9 | bench: clean setup # Run benchmarks 10 | go test -run=none -bench=. -benchmem benchmark_test.go 11 | 12 | setup: 13 | 14 | clean: ## Remove artifacts 15 | @rm -f model/*_easyjson.go 16 | 17 | .PHONY: clean bench setup test 18 | -------------------------------------------------------------------------------- /_examples/go.sum: -------------------------------------------------------------------------------- 1 | github.com/elastic/elastic-transport-go/v8 v8.0.0-20211202110751-50105067ef27 h1:O58SwZ7pdt7Lzy8JqpJubJlgDbr9jVV7ro4HFPvaZDw= 2 | github.com/elastic/elastic-transport-go/v8 v8.0.0-20211202110751-50105067ef27/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI= 3 | github.com/elastic/go-elasticsearch/v8 v8.0.0-20211123103400-5f8a17a2322f h1:m4o9rvJO5TNlTmpZ2RMsD96Y6ezWM+loFzQG2RCbHTc= 4 | github.com/elastic/go-elasticsearch/v8 v8.0.0-20211123103400-5f8a17a2322f/go.mod h1:xe9a/L2aeOgFKKgrO3ibQTnMdpAeL0GC+5/HpGScSa4= 5 | -------------------------------------------------------------------------------- /.doc/examples/doc/2fd69fb0538e4f36ac69a8b8f8bf5ae8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_2fd69fb0538e4f36ac69a8b8f8bf5ae8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.UpdateByQuery( 6 | []string{"twitter"}, 7 | es.UpdateByQuery.WithBody(strings.NewReader(`{ 8 | "script": { 9 | "source": "ctx._source.likes++", 10 | "lang": "painless" 11 | }, 12 | "query": { 13 | "term": { 14 | "user": "kimchy" 15 | } 16 | } 17 | }`)), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/4acf902c2598b2558f34f20c1744c433.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_4acf902c2598b2558f34f20c1744c433_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Indices.Refresh() 7 | fmt.Println(res, err) 8 | } 9 | 10 | { 11 | res, err := es.Search( 12 | es.Search.WithIndex("twitter"), 13 | es.Search.WithFilterPath("hits.total"), 14 | es.Search.WithQuery("extra:test"), 15 | es.Search.WithSize(0), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | } 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/8ad4a5ea7657eba25dc9a0ea994cf07d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-wildcard-query_8ad4a5ea7657eba25dc9a0ea994cf07d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "wildcard": { 9 | "user": { 10 | "value": "ki*y", 11 | "boost": 1.0, 12 | "rewrite": "constant_score" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/e30ea6e3823a139d7693d8cce1920a06.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_e30ea6e3823a139d7693d8cce1920a06_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "this is a test", 10 | "fields": [ 11 | "subject^3", 12 | "message" 13 | ] 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/f32f0c19b42de3b87dd764fe4ca17e7c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_f32f0c19b42de3b87dd764fe4ca17e7c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "default_field": "title", 10 | "query": "ny city", 11 | "auto_generate_synonyms_phrase_query": false 12 | } 13 | } 14 | }`)), 15 | es.Search.WithPretty(), 16 | ) 17 | fmt.Println(res, err) 18 | ---- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/5c2f486c27bd5346e512265f93375d16.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-range-query_5c2f486c27bd5346e512265f93375d16_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "range": { 9 | "timestamp": { 10 | "time_zone": "+01:00", 11 | "gte": "2020-01-01T00:00:00", 12 | "lte": "now" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/a34d70d7022eb4ba48909d440c80390f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from api-conventions_a34d70d7022eb4ba48909d440c80390f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("%3Clogstash-%7Bnow%2Fd-2d%7D%3E%2C%3Clogstash-%7Bnow%2Fd-1d%7D%3E%2C%3Clogstash-%7Bnow%2Fd%7D%3E"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match": { 10 | "test": "data" 11 | } 12 | } 13 | }`)), 14 | es.Search.WithPretty(), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/d3dccdb15822e971ededb9f6f7d8ada1.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_d3dccdb15822e971ededb9f6f7d8ada1_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "content", 11 | "name.*^5" 12 | ], 13 | "query": "this AND that OR thus" 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/20a36eb5a76396b7febf7b7166366f30.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_20a36eb5a76396b7febf7b7166366f30_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("twitter"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "size": 100, 9 | "query": { 10 | "match": { 11 | "title": "elasticsearch" 12 | } 13 | } 14 | }`)), 15 | es.Search.WithScroll(time.Duration(60000000000)), 16 | es.Search.WithPretty(), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/472ec8c57fec8457e31fe6dd7f6e3713.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_472ec8c57fec8457e31fe6dd7f6e3713_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "title" 11 | ], 12 | "query": "this that thus", 13 | "minimum_should_match": 2 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/4b90feb9d5d3dbfce424dac0341320b7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_4b90feb9d5d3dbfce424dac0341320b7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match_all": {} 10 | }, 11 | "sort": [ 12 | { 13 | "account_number": "asc" 14 | } 15 | ], 16 | "from": 10, 17 | "size": 10 18 | }`)), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/85479e02af00681210e17e3d0ff51e21.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-types-date_85479e02af00681210e17e3d0ff51e21_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "date": { 11 | "type": "date", 12 | "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" 13 | } 14 | } 15 | } 16 | }`)), 17 | ) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/typedapi/examples/index.asciidoc: -------------------------------------------------------------------------------- 1 | [[examples]] 2 | === Examples 3 | 4 | This sections lists a series of frequent use cases that will help you start with this new API. 5 | 6 | * <> 7 | * <> 8 | * <> 9 | * <> 10 | * <> 11 | 12 | NOTE: This is a work in progress, the documentation will evolve in the future. 13 | 14 | include::indices.asciidoc[] 15 | include::indexing.asciidoc[] 16 | include::getdoc.asciidoc[] 17 | include::search.asciidoc[] 18 | include::aggregations.asciidoc[] -------------------------------------------------------------------------------- /.doc/examples/doc/2fea3e324939cc7e9c396964aeee7111.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-match-query_2fea3e324939cc7e9c396964aeee7111_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "match": { 9 | "message": { 10 | "query": "to be or not to be", 11 | "operator": "and", 12 | "zero_terms_query": "all" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/54a215d242ab65123b09e9dfb71bcbbf.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_54a215d242ab65123b09e9dfb71bcbbf_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "field": "genre", 11 | "order": { 12 | "_key": "asc" 13 | } 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/9403764e6eccad7b321b65e9a10c5727.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_9403764e6eccad7b321b65e9a10c5727_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "tags": { 9 | "terms": { 10 | "field": "tags", 11 | "include": ".*sport.*", 12 | "exclude": "water_.*" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/b607eea422295a3e9acd75f9ed1c8cb7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_b607eea422295a3e9acd75f9ed1c8cb7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "sort": [ 8 | { 9 | "price": { 10 | "missing": "_last" 11 | } 12 | } 13 | ], 14 | "query": { 15 | "term": { 16 | "product": "chocolate" 17 | } 18 | } 19 | }`)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/c5802e9f3f4068fcecb6937b867b270d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_c5802e9f3f4068fcecb6937b867b270d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "field": "genre", 11 | "order": { 12 | "_count": "asc" 13 | } 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.buildkite/pipeline.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - label: ":elasticsearch: :golang: Elasticsearch Go Test Suite: {{ matrix.suite }}" 3 | agents: 4 | provider: "gcp" 5 | env: 6 | TEST_SUITE: "{{ matrix.suite }}" 7 | STACK_VERSION: 8.14.0-SNAPSHOT 8 | WORKSPACE: /tmp/go-elasticsearch 9 | matrix: 10 | setup: 11 | suite: 12 | - "free" 13 | - "platinum" 14 | command: ./.buildkite/run-tests 15 | artifact_paths: "elasticsearch-api/tmp/*" 16 | - wait: ~ 17 | continue_on_failure: true 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/0bcd380315ef4691b8c79df6ca53a85f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_0bcd380315ef4691b8c79df6ca53a85f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "sort": [ 8 | { 9 | "price": { 10 | "unmapped_type": "long" 11 | } 12 | } 13 | ], 14 | "query": { 15 | "term": { 16 | "product": "chocolate" 17 | } 18 | } 19 | }`)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/436d50b85fc8f0977d02059eec00719b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_436d50b85fc8f0977d02059eec00719b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "script": { 10 | "source": "ctx._source.counter += params.count", 11 | "lang": "painless", 12 | "params": { 13 | "count": 4 14 | } 15 | }, 16 | "upsert": { 17 | "counter": 1 18 | } 19 | }`), 20 | es.Update.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/e60ded7becfd5b2ccaef5bad2aaa93f5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_e60ded7becfd5b2ccaef5bad2aaa93f5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "products": { 9 | "terms": { 10 | "field": "product", 11 | "size": 5, 12 | "show_term_doc_count_error": true 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/0d6ad80b5241552dd27af1a81c2eeb37.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_0d6ad80b5241552dd27af1a81c2eeb37_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "script": { 10 | "source": "if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'none' }", 11 | "lang": "painless", 12 | "params": { 13 | "tag": "green" 14 | } 15 | } 16 | }`), 17 | es.Update.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/1a803a6933babd15207499307cc325f8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_1a803a6933babd15207499307cc325f8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test1", 10 | "alias": "alias1" 11 | } 12 | }, 13 | { 14 | "add": { 15 | "index": "test2", 16 | "alias": "alias1" 17 | } 18 | } 19 | ] 20 | }`), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/1bc731a4df952228af6dfa6b48627332.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_1bc731a4df952228af6dfa6b48627332_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "max_docs": 10, 8 | "source": { 9 | "index": "twitter", 10 | "query": { 11 | "function_score": { 12 | "random_score": {}, 13 | "min_score": 0.9 14 | } 15 | } 16 | }, 17 | "dest": { 18 | "index": "random_twitter" 19 | } 20 | }`)) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/53d61793dc11f2a8108a0b08875a637d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_53d61793dc11f2a8108a0b08875a637d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test1", 10 | "alias": "alias2", 11 | "filter": { 12 | "term": { 13 | "user": "kimchy" 14 | } 15 | } 16 | } 17 | } 18 | ] 19 | }`), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/e7eca57a5bf5a53cbbe2463bce11495b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-metrics-valuecount-aggregation_e7eca57a5bf5a53cbbe2463bce11495b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "types_count": { 10 | "value_count": { 11 | "field": "type" 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithSize(0), 17 | es.Search.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/0e118857b815b62118a30c042f079db1.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_0e118857b815b62118a30c042f079db1_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "quick brown f", 10 | "type": "phrase_prefix", 11 | "fields": [ 12 | "subject", 13 | "message" 14 | ] 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/14701dcc0cca9665fce2aace0cb62af7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_14701dcc0cca9665fce2aace0cb62af7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("twitter"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "range": { 10 | "likes": { 11 | "lt": 10 12 | } 13 | } 14 | } 15 | }`)), 16 | es.Search.WithFilterPath("hits.total"), 17 | es.Search.WithSize(0), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/68721288dc9ad8aa1b55099b4d303051.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_68721288dc9ad8aa1b55099b4d303051_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "quick brown f", 10 | "type": "bool_prefix", 11 | "fields": [ 12 | "subject", 13 | "message" 14 | ] 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/6d5b9b693f2b59abd5aedcb5c8c9cec8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-create-index_6d5b9b693f2b59abd5aedcb5c8c9cec8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "test", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "aliases": { 9 | "alias_1": {}, 10 | "alias_2": { 11 | "filter": { 12 | "term": { 13 | "user": "kimchy" 14 | } 15 | }, 16 | "routing": "kimchy" 17 | } 18 | } 19 | }`)), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/b91294751233d4d7e758400b9ea56fb5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_b91294751233d4d7e758400b9ea56fb5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "remove": { 9 | "index": "test1", 10 | "alias": "alias1" 11 | } 12 | }, 13 | { 14 | "add": { 15 | "index": "test1", 16 | "alias": "alias2" 17 | } 18 | } 19 | ] 20 | }`), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/151d2b11807ec684b0c01aa89189a801.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_151d2b11807ec684b0c01aa89189a801_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "title", 11 | "content" 12 | ], 13 | "query": "this that thus", 14 | "minimum_should_match": 2 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/8ecefdcf8f153cf91588e9fdde8f3e6b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_8ecefdcf8f153cf91588e9fdde8f3e6b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "content", 11 | "name^5" 12 | ], 13 | "query": "this AND that OR thus", 14 | "tie_breaker": 0 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/a692b4c0ca7825c467880b346841f5a5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_a692b4c0ca7825c467880b346841f5a5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "name": { 11 | "properties": { 12 | "first": { 13 | "type": "text" 14 | } 15 | } 16 | } 17 | } 18 | } 19 | }`)), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/ba770c774af72e54b2b5a503b5332c71.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_ba770c774af72e54b2b5a503b5332c71_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "script": { 11 | "source": "doc['genre'].value", 12 | "lang": "painless" 13 | } 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/fa88f6f5a7d728ec4f1d05244228cb09.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-bool-query_fa88f6f5a7d728ec4f1d05244228cb09_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "bool": { 9 | "must": { 10 | "match_all": {} 11 | }, 12 | "filter": { 13 | "term": { 14 | "status": "active" 15 | } 16 | } 17 | } 18 | } 19 | }`)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/4955bae30f265b9e436f82b015de6d7e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-terms-query_4955bae30f265b9e436f82b015de6d7e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "terms": { 10 | "color": { 11 | "index": "my-index-000001", 12 | "id": "2", 13 | "path": "color" 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/ad2416ca0581316cee6c63129685bca5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_ad2416ca0581316cee6c63129685bca5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "title", 11 | "content" 12 | ], 13 | "query": "this OR that OR thus", 14 | "minimum_should_match": 2 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/bfdad8a928ea30d7cf60d0a0a6bc6e2e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-bulk_bfdad8a928ea30d7cf60d0a0a6bc6e2e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Bulk( 6 | strings.NewReader(` 7 | { "update": {"_id": "5", "_index": "index1"} } 8 | { "doc": {"my_field": "baz"} } 9 | { "update": {"_id": "6", "_index": "index1"} } 10 | { "doc": {"my_field": "baz"} } 11 | { "update": {"_id": "7", "_index": "index1"} } 12 | { "doc": {"my_field": "baz"} } 13 | `), 14 | es.Bulk.WithFilterPath("items.*.error"), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/eff2fc92d46eb3c8f4d424eed18f54a2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-function-score-query_eff2fc92d46eb3c8f4d424eed18f54a2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "function_score": { 9 | "query": { 10 | "match_all": {} 11 | }, 12 | "boost": "5", 13 | "random_score": {}, 14 | "boost_mode": "multiply" 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /catalog-info.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: backstage.io/v1alpha1 2 | kind: Resource 3 | metadata: 4 | name: buildkite-pipeline-go-elasticsearch 5 | spec: 6 | implementation: 7 | apiVersion: buildkite.elastic.dev/v1 8 | kind: Pipeline 9 | metadata: 10 | description: Elasticsearch Go Client 11 | name: go-elasticsearch 12 | spec: 13 | repository: elastic/go-elasticsearch 14 | teams: 15 | clients-team: {} 16 | everyone: 17 | access_level: READ_ONLY 18 | owner: group:clients-team 19 | type: buildkite-pipeline 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/64b9baa6d7556b960b29698f3383aa31.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_64b9baa6d7556b960b29698f3383aa31_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "remote": { 9 | "host": "http://otherhost:9200" 10 | }, 11 | "index": "source", 12 | "size": 10, 13 | "query": { 14 | "match": { 15 | "test": "data" 16 | } 17 | } 18 | }, 19 | "dest": { 20 | "index": "dest" 21 | } 22 | }`)) 23 | fmt.Println(res, err) 24 | ---- 25 | -------------------------------------------------------------------------------- /.doc/examples/doc/8871b8fcb6de4f0c7dff22798fb10fb7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_8871b8fcb6de4f0c7dff22798fb10fb7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "twitter" 9 | }, 10 | "dest": { 11 | "index": "new_twitter", 12 | "version_type": "external" 13 | }, 14 | "script": { 15 | "source": "if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}", 16 | "lang": "painless" 17 | } 18 | }`)) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/8a1f6cffa653800282c0ae160ee375bc.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_8a1f6cffa653800282c0ae160ee375bc_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "test", 7 | "1", 8 | strings.NewReader(`{ 9 | "script": { 10 | "source": "if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }", 11 | "lang": "painless", 12 | "params": { 13 | "tag": "blue" 14 | } 15 | } 16 | }`), 17 | es.Update.WithPretty(), 18 | ) 19 | fmt.Println(res, err) 20 | ---- 21 | -------------------------------------------------------------------------------- /.doc/examples/doc/973a3ff47fc4ce036ecd9bd363fef9f7.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_973a3ff47fc4ce036ecd9bd363fef9f7_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "index": "metricbeat-*" 9 | }, 10 | "dest": { 11 | "index": "metricbeat" 12 | }, 13 | "script": { 14 | "lang": "painless", 15 | "source": "ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'" 16 | } 17 | }`)) 18 | fmt.Println(res, err) 19 | ---- 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/ae9ccfaa146731ab9176df90670db1c2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-bulk_ae9ccfaa146731ab9176df90670db1c2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Bulk( 6 | strings.NewReader(` 7 | { "index" : { "_index" : "test", "_id" : "1" } } 8 | { "field1" : "value1" } 9 | { "delete" : { "_index" : "test", "_id" : "2" } } 10 | { "create" : { "_index" : "test", "_id" : "3" } } 11 | { "field1" : "value3" } 12 | { "update" : {"_id" : "1", "_index" : "test"} } 13 | { "doc" : {"field2" : "value2"} } 14 | `), 15 | ) 16 | fmt.Println(res, err) 17 | ---- 18 | -------------------------------------------------------------------------------- /.doc/examples/doc/ff1c66932f244050213f0c3cbcc214f9.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-regexp-query_ff1c66932f244050213f0c3cbcc214f9_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "regexp": { 9 | "user": { 10 | "value": "k.*y", 11 | "flags": "ALL", 12 | "max_determinized_states": 10000, 13 | "rewrite": "constant_score" 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/7fef68840761c6982c14ad7af96caf37.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-types-nested_7fef68840761c6982c14ad7af96caf37_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Index( 6 | "my-index-000001", 7 | strings.NewReader(`{ 8 | "group": "fans", 9 | "user": [ 10 | { 11 | "first": "John", 12 | "last": "Smith" 13 | }, 14 | { 15 | "first": "Alice", 16 | "last": "White" 17 | } 18 | ] 19 | }`), 20 | es.Index.WithDocumentID("1"), 21 | es.Index.WithPretty(), 22 | ) 23 | fmt.Println(res, err) 24 | ---- 25 | -------------------------------------------------------------------------------- /.doc/examples/doc/b94cee0f74f57742b3948f9b784dfdd4.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_b94cee0f74f57742b3948f9b784dfdd4_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.ClearScroll( 6 | es.ClearScroll.WithScrollID("DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==", "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAABFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAAAxZrUllkUVlCa1NqNmRMaUhiQlZkMWFBAAAAAAAAAAIWa1JZZFFZQmtTajZkTGlIYkJWZDFhQQAAAAAAAAAFFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAABBZrUllkUVlCa1NqNmRMaUhiQlZkMWFB"), 7 | ) 8 | fmt.Println(res, err) 9 | ---- 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/ca51c02a2abd0f87c52448cd7b93a96d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-function-score-query_ca51c02a2abd0f87c52448cd7b93a96d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "function_score": { 9 | "field_value_factor": { 10 | "field": "likes", 11 | "factor": 1.2, 12 | "modifier": "sqrt", 13 | "missing": 1 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/913770050ebbf3b9b549a899bc11060a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-get_913770050ebbf3b9b549a899bc11060a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "twitter", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "counter": { 11 | "type": "integer", 12 | "store": false 13 | }, 14 | "tags": { 15 | "type": "keyword", 16 | "store": true 17 | } 18 | } 19 | } 20 | }`)), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/5da6efd5b038ada64c9e853c88c1ec47.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_5da6efd5b038ada64c9e853c88c1ec47_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "brown fox", 10 | "type": "best_fields", 11 | "fields": [ 12 | "subject", 13 | "message" 14 | ], 15 | "tie_breaker": 0.3 16 | } 17 | } 18 | }`)), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/047266b0d20fdb62ebc72d51952c8f6d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_047266b0d20fdb62ebc72d51952c8f6d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "Will Smith", 10 | "type": "cross_fields", 11 | "fields": [ 12 | "first_name", 13 | "last_name" 14 | ], 15 | "operator": "and" 16 | } 17 | } 18 | }`)), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/4af6bd63a66b356748bed529ccbd1355.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_4af6bd63a66b356748bed529ccbd1355_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test", 10 | "alias": "alias1", 11 | "is_write_index": true 12 | } 13 | }, 14 | { 15 | "add": { 16 | "index": "test2", 17 | "alias": "alias1" 18 | } 19 | } 20 | ] 21 | }`), 22 | ) 23 | fmt.Println(res, err) 24 | ---- 25 | -------------------------------------------------------------------------------- /.doc/examples/doc/a7e58d4dc477a84c1306fd5749aafd8b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping_a7e58d4dc477a84c1306fd5749aafd8b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "age": { 11 | "type": "integer" 12 | }, 13 | "email": { 14 | "type": "keyword" 15 | }, 16 | "name": { 17 | "type": "text" 18 | } 19 | } 20 | } 21 | }`)), 22 | ) 23 | fmt.Println(res, err) 24 | ---- 25 | -------------------------------------------------------------------------------- /.doc/examples/doc/d8c857bbceed72c990038f1ef9d4f9e9.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_d8c857bbceed72c990038f1ef9d4f9e9_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "field": "genre", 11 | "script": { 12 | "source": "'Genre: ' +_value", 13 | "lang": "painless" 14 | } 15 | } 16 | } 17 | } 18 | }`)), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/e270f3f721a5712cd11a5ca03554f5b0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_e270f3f721a5712cd11a5ca03554f5b0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "Will Smith", 10 | "type": "best_fields", 11 | "fields": [ 12 | "first_name", 13 | "last_name" 14 | ], 15 | "operator": "and" 16 | } 17 | } 18 | }`)), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/05d03b7be5fa4f34887044fccb75fbd0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_05d03b7be5fa4f34887044fccb75fbd0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "script": { 11 | "id": "my_script", 12 | "params": { 13 | "field": "genre" 14 | } 15 | } 16 | } 17 | } 18 | } 19 | }`)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/095d60b2cfc5004c97efc49f27287262.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_095d60b2cfc5004c97efc49f27287262_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "sales_over_time": { 10 | "date_histogram": { 11 | "field": "date", 12 | "fixed_interval": "30d" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithSize(0), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/7b908b1189f076942de8cd497ff1fa59.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_7b908b1189f076942de8cd497ff1fa59_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "quick brown fox", 10 | "type": "most_fields", 11 | "fields": [ 12 | "title", 13 | "title.original", 14 | "title.shingles" 15 | ] 16 | } 17 | } 18 | }`)), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/ad0dcbc7fc619e952c8825b8f307b7b2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_ad0dcbc7fc619e952c8825b8f307b7b2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "Jon", 10 | "type": "cross_fields", 11 | "fields": [ 12 | "first", 13 | "first.edge", 14 | "last", 15 | "last.edge" 16 | ] 17 | } 18 | } 19 | }`)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/f43d551aaaad73d979adf1b86533e6a3.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_f43d551aaaad73d979adf1b86533e6a3_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "sales_over_time": { 10 | "date_histogram": { 11 | "field": "date", 12 | "fixed_interval": "2w" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithSize(0), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/179f0a3e84ff4bbac18787a018eabf89.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_179f0a3e84ff4bbac18787a018eabf89_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "multi_match": { 9 | "query": "Jon", 10 | "type": "cross_fields", 11 | "analyzer": "standard", 12 | "fields": [ 13 | "first", 14 | "last", 15 | "*.edge" 16 | ] 17 | } 18 | } 19 | }`)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/25576b6773322f0929d4c635a940dba0.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-query-string-query_25576b6773322f0929d4c635a940dba0_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "query_string": { 9 | "fields": [ 10 | "title", 11 | "content" 12 | ], 13 | "query": "this OR that OR thus", 14 | "type": "cross_fields", 15 | "minimum_should_match": 2 16 | } 17 | } 18 | }`)), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/af44cc7fb0c435d4497c77baf904bf5e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_af44cc7fb0c435d4497c77baf904bf5e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "sales_over_time": { 10 | "date_histogram": { 11 | "field": "date", 12 | "calendar_interval": "month" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithSize(0), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/afef5cac988592b97ae289ab39c2f437.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-params-fielddata_afef5cac988592b97ae289ab39c2f437_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "my_field": { 11 | "type": "text", 12 | "fields": { 13 | "keyword": { 14 | "type": "keyword" 15 | } 16 | } 17 | } 18 | } 19 | } 20 | }`)), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/f5815d573cee0447910c9668003887b8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_f5815d573cee0447910c9668003887b8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "sales_over_time": { 10 | "date_histogram": { 11 | "field": "date", 12 | "calendar_interval": "2d" 13 | } 14 | } 15 | } 16 | }`)), 17 | es.Search.WithSize(0), 18 | es.Search.WithPretty(), 19 | ) 20 | fmt.Println(res, err) 21 | ---- 22 | -------------------------------------------------------------------------------- /.doc/examples/doc/2615aaced23fbe827cbc00c364e4bd4f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-metrics-valuecount-aggregation_2615aaced23fbe827cbc00c364e4bd4f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "type_count": { 10 | "value_count": { 11 | "script": { 12 | "source": "doc['type'].value" 13 | } 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithSize(0), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/8552f4f3bfd69515b883ff43888a199b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_8552f4f3bfd69515b883ff43888a199b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "sort": [ 8 | { 9 | "_geo_distance": { 10 | "pin.location": "40,-70", 11 | "order": "asc", 12 | "unit": "km" 13 | } 14 | } 15 | ], 16 | "query": { 17 | "term": { 18 | "user": "kimchy" 19 | } 20 | } 21 | }`)), 22 | es.Search.WithPretty(), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/typedapi/conventions/requests.asciidoc: -------------------------------------------------------------------------------- 1 | [[requests]] 2 | ==== Requests 3 | 4 | Requests are modeled around structures that follows as closely as possible the {es} API and uses the standard `json/encoding` for serialization. 5 | Corresponding request can be found withing the same package as its endpoint and comes with a Builder that allows you to deep dive into the API by following the types. 6 | 7 | [source,go] 8 | ------------------------------------ 9 | types.Query{ 10 | Term: map[string]types.TermQuery{ 11 | "name": {Value: "Foo"}, 12 | }, 13 | } 14 | ------------------------------------ -------------------------------------------------------------------------------- /.doc/examples/doc/36b2778f23d0955255f52c075c4d213d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_36b2778f23d0955255f52c075c4d213d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "remote": { 9 | "host": "http://otherhost:9200", 10 | "username": "user", 11 | "password": "pass" 12 | }, 13 | "index": "source", 14 | "query": { 15 | "match": { 16 | "test": "data" 17 | } 18 | } 19 | }, 20 | "dest": { 21 | "index": "dest" 22 | } 23 | }`)) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/5275842787967b6db876025f4a1c6942.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-suggesters_5275842787967b6db876025f4a1c6942_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "suggest": { 8 | "text": "tring out Elasticsearch", 9 | "my-suggest-1": { 10 | "term": { 11 | "field": "message" 12 | } 13 | }, 14 | "my-suggest-2": { 15 | "term": { 16 | "field": "user" 17 | } 18 | } 19 | } 20 | }`)), 21 | es.Search.WithPretty(), 22 | ) 23 | fmt.Println(res, err) 24 | ---- 25 | -------------------------------------------------------------------------------- /.doc/examples/doc/9beb260834f8cfb240f6308950dbb9c2.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_9beb260834f8cfb240f6308950dbb9c2_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "sort": [ 8 | { 9 | "_geo_distance": { 10 | "pin.location": "drm3btev3e86", 11 | "order": "asc", 12 | "unit": "km" 13 | } 14 | } 15 | ], 16 | "query": { 17 | "term": { 18 | "user": "kimchy" 19 | } 20 | } 21 | }`)), 22 | es.Search.WithPretty(), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/a22f1a6661a074a07041a710e4da6d50.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_a22f1a6661a074a07041a710e4da6d50_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("twitter"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "slice": { 9 | "field": "date", 10 | "id": 0, 11 | "max": 10 12 | }, 13 | "query": { 14 | "match": { 15 | "title": "elasticsearch" 16 | } 17 | } 18 | }`)), 19 | es.Search.WithScroll(time.Duration(60000000000)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/f9fec6ec9a7da3d35ac674712bd5b813.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-function-score-query_f9fec6ec9a7da3d35ac674712bd5b813_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "function_score": { 9 | "gauss": { 10 | "date": { 11 | "origin": "2013-09-17", 12 | "scale": "10d", 13 | "offset": "5d", 14 | "decay": 0.5 15 | } 16 | } 17 | } 18 | } 19 | }`)), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/7f697eb436dfa3c30dfe610d8c32d132.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_7f697eb436dfa3c30dfe610d8c32d132_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Reindex( 6 | strings.NewReader(`{ 7 | "source": { 8 | "remote": { 9 | "host": "http://otherhost:9200", 10 | "socket_timeout": "1m", 11 | "connect_timeout": "10s" 12 | }, 13 | "index": "source", 14 | "query": { 15 | "match": { 16 | "test": "data" 17 | } 18 | } 19 | }, 20 | "dest": { 21 | "index": "dest" 22 | } 23 | }`)) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/e22ef762d6020157e3514d3cda16599c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-aliases_e22ef762d6020157e3514d3cda16599c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.UpdateAliases(strings.NewReader(`{ 6 | "actions": [ 7 | { 8 | "add": { 9 | "index": "test", 10 | "alias": "alias1", 11 | "is_write_index": false 12 | } 13 | }, 14 | { 15 | "add": { 16 | "index": "test2", 17 | "alias": "alias1", 18 | "is_write_index": true 19 | } 20 | } 21 | ] 22 | }`), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /_examples/bulk/Makefile: -------------------------------------------------------------------------------- 1 | GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test) 2 | export ELASTICSEARCH_URL=http://elastic:elastic@localhost:9200 3 | 4 | test: test-default test-indexer 5 | 6 | test-default: 7 | go run default.go 8 | 9 | test-indexer: 10 | go run indexer.go 11 | 12 | test-benchmarks: clean setup 13 | cd benchmarks && go run benchmarks.go 14 | 15 | setup: 16 | go install github.com/mailru/easyjson/easyjson@latest 17 | cd benchmarks && go generate ./model 18 | 19 | clean: 20 | @rm -f benchmarks/model/*_easyjson.go 21 | 22 | .PHONY: test test-default test-indexer test-benchmarks setup clean 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/316cd43feb3b86396483903af1a048b1.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_316cd43feb3b86396483903af1a048b1_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "sale_date": { 10 | "date_histogram": { 11 | "field": "date", 12 | "calendar_interval": "year", 13 | "missing": "2000/01/01" 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithSize(0), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/6ce0585ab13a480796add86de6b2037c.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_6ce0585ab13a480796add86de6b2037c_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Index( 7 | "users", 8 | strings.NewReader(`{ 9 | "user_id": 12345 10 | }`), 11 | es.Index.WithRefresh("wait_for"), 12 | es.Index.WithPretty(), 13 | ) 14 | fmt.Println(res, err) 15 | } 16 | 17 | { 18 | res, err := es.Index( 19 | "users", 20 | strings.NewReader(`{ 21 | "user_id": 12346 22 | }`), 23 | es.Index.WithRefresh("wait_for"), 24 | es.Index.WithPretty(), 25 | ) 26 | fmt.Println(res, err) 27 | } 28 | ---- 29 | -------------------------------------------------------------------------------- /.doc/examples/doc/9bfdda207b701028a3439e495e800c02.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_9bfdda207b701028a3439e495e800c02_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "sales_over_time": { 10 | "date_histogram": { 11 | "field": "date", 12 | "calendar_interval": "1M", 13 | "format": "yyyy-MM-dd" 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithSize(0), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/e6b972611c0ec8ab4c240f33f323d85b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_e6b972611c0ec8ab4c240f33f323d85b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "by_day": { 10 | "date_histogram": { 11 | "field": "date", 12 | "calendar_interval": "day", 13 | "time_zone": "-01:00" 14 | } 15 | } 16 | } 17 | }`)), 18 | es.Search.WithSize(0), 19 | es.Search.WithPretty(), 20 | ) 21 | fmt.Println(res, err) 22 | ---- 23 | -------------------------------------------------------------------------------- /.doc/examples/doc/2533e4b36ae837eaecda08407ecb6383.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-suggesters_2533e4b36ae837eaecda08407ecb6383_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "suggest": { 8 | "my-suggest-1": { 9 | "text": "tring out Elasticsearch", 10 | "term": { 11 | "field": "message" 12 | } 13 | }, 14 | "my-suggest-2": { 15 | "text": "kmichy", 16 | "term": { 17 | "field": "user" 18 | } 19 | } 20 | } 21 | }`)), 22 | es.Search.WithPretty(), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/1da77e114459e0b77d78a3dcc8fae429.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-put-mapping_1da77e114459e0b77d78a3dcc8fae429_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Indices.Create("twitter-1") 7 | fmt.Println(res, err) 8 | } 9 | 10 | { 11 | res, err := es.Indices.Create( 12 | "twitter-2", 13 | ) 14 | fmt.Println(res, err) 15 | } 16 | 17 | { 18 | res, err := es.Indices.PutMapping( 19 | []string{"twitter-1,twitter-2"}, 20 | strings.NewReader(`{ 21 | "properties": { 22 | "user_name": { 23 | "type": "text" 24 | } 25 | } 26 | }`), 27 | ) 28 | fmt.Println(res, err) 29 | } 30 | ---- 31 | -------------------------------------------------------------------------------- /_examples/security/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/elastic/go-elasticsearch/v8/_examples/security 2 | 3 | go 1.21 4 | 5 | toolchain go1.21.8 6 | 7 | replace github.com/elastic/go-elasticsearch/v8 => ../.. 8 | 9 | require github.com/elastic/go-elasticsearch/v8 v8.0.0-00010101000000-000000000000 10 | 11 | require ( 12 | github.com/elastic/elastic-transport-go/v8 v8.4.0 // indirect 13 | github.com/go-logr/logr v1.3.0 // indirect 14 | github.com/go-logr/stdr v1.2.2 // indirect 15 | go.opentelemetry.io/otel v1.21.0 // indirect 16 | go.opentelemetry.io/otel/metric v1.21.0 // indirect 17 | go.opentelemetry.io/otel/trace v1.21.0 // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/4832108e01f5efac5e6e40ac405998ca.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update_4832108e01f5efac5e6e40ac405998ca_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Update( 6 | "sessions", 7 | "dh3sgudg8gsrgl", 8 | strings.NewReader(`{ 9 | "scripted_upsert": true, 10 | "script": { 11 | "id": "my_web_session_summariser", 12 | "params": { 13 | "pageViewEvent": { 14 | "url": "foo.com/bar", 15 | "response": 404, 16 | "time": "2014-01-01 12:32" 17 | } 18 | } 19 | }, 20 | "upsert": {} 21 | }`), 22 | es.Update.WithPretty(), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/25429a303a53d06fd0151f3618013ee4.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_25429a303a53d06fd0151f3618013ee4_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "dayOfWeek": { 10 | "terms": { 11 | "script": { 12 | "lang": "painless", 13 | "source": "doc['date'].value.dayOfWeekEnum.value" 14 | } 15 | } 16 | } 17 | } 18 | }`)), 19 | es.Search.WithSize(0), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/4342ccf6cc24fd80bd3cd1f9a4c2ef8e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-scroll_4342ccf6cc24fd80bd3cd1f9a4c2ef8e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.ClearScroll( 6 | es.ClearScroll.WithBody(strings.NewReader(`{ 7 | "scroll_id": [ 8 | "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==", 9 | "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAABFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAAAxZrUllkUVlCa1NqNmRMaUhiQlZkMWFBAAAAAAAAAAIWa1JZZFFZQmtTajZkTGlIYkJWZDFhQQAAAAAAAAAFFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAABBZrUllkUVlCa1NqNmRMaUhiQlZkMWFB" 10 | ] 11 | }`)), 12 | ) 13 | fmt.Println(res, err) 14 | ---- 15 | -------------------------------------------------------------------------------- /.doc/examples/doc/626f8c4b3e2cd3d9beaa63a7f5799d7a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-suggesters_626f8c4b3e2cd3d9beaa63a7f5799d7a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("twitter"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "match": { 10 | "message": "tring out Elasticsearch" 11 | } 12 | }, 13 | "suggest": { 14 | "my-suggestion": { 15 | "text": "tring out Elasticsearch", 16 | "term": { 17 | "field": "message" 18 | } 19 | } 20 | } 21 | }`)), 22 | es.Search.WithPretty(), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/aee4734ee63dbbbd12a21ee886f7a829.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_aee4734ee63dbbbd12a21ee886f7a829_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "sort": [ 8 | { 9 | "_geo_distance": { 10 | "pin.location": [ 11 | -70, 12 | 40 13 | ], 14 | "order": "asc", 15 | "unit": "km" 16 | } 17 | } 18 | ], 19 | "query": { 20 | "term": { 21 | "user": "kimchy" 22 | } 23 | } 24 | }`)), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | ---- 29 | -------------------------------------------------------------------------------- /_examples/cloudfunction/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/elastic/go-elasticsearch/v8/_examples/clusterstatus 2 | 3 | go 1.21 4 | 5 | toolchain go1.21.8 6 | 7 | replace github.com/elastic/go-elasticsearch/v8 => ../.. 8 | 9 | require github.com/elastic/go-elasticsearch/v8 v8.0.0-20210817150010-57d659deaca7 10 | 11 | require ( 12 | github.com/elastic/elastic-transport-go/v8 v8.4.0 // indirect 13 | github.com/go-logr/logr v1.3.0 // indirect 14 | github.com/go-logr/stdr v1.2.2 // indirect 15 | go.opentelemetry.io/otel v1.21.0 // indirect 16 | go.opentelemetry.io/otel/metric v1.21.0 // indirect 17 | go.opentelemetry.io/otel/trace v1.21.0 // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/251ea12c1248385ab409906ac64d9ee9.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_251ea12c1248385ab409906ac64d9ee9_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "bool": { 10 | "must": { 11 | "match_all": {} 12 | }, 13 | "filter": { 14 | "range": { 15 | "balance": { 16 | "gte": 20000, 17 | "lte": 30000 18 | } 19 | } 20 | } 21 | } 22 | } 23 | }`)), 24 | es.Search.WithPretty(), 25 | ) 26 | fmt.Println(res, err) 27 | ---- 28 | -------------------------------------------------------------------------------- /.doc/examples/doc/3e573bfabe00f8bfb8bb69aa5820768e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-delete-by-query_3e573bfabe00f8bfb8bb69aa5820768e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Indices.Refresh() 7 | fmt.Println(res, err) 8 | } 9 | 10 | { 11 | res, err := es.Search( 12 | es.Search.WithIndex("twitter"), 13 | es.Search.WithBody(strings.NewReader(`{ 14 | "query": { 15 | "range": { 16 | "likes": { 17 | "lt": 10 18 | } 19 | } 20 | } 21 | }`)), 22 | es.Search.WithFilterPath("hits.total"), 23 | es.Search.WithSize(0), 24 | es.Search.WithPretty(), 25 | ) 26 | fmt.Println(res, err) 27 | } 28 | ---- 29 | -------------------------------------------------------------------------------- /.doc/examples/doc/4c95d54b32df4dc49e9762b6c1ae2c05.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-params-fielddata_4c95d54b32df4dc49e9762b6c1ae2c05_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "tag": { 11 | "type": "text", 12 | "fielddata": true, 13 | "fielddata_frequency_filter": { 14 | "min": 0.001, 15 | "max": 0.1, 16 | "min_segment_size": 500 17 | } 18 | } 19 | } 20 | } 21 | }`)), 22 | ) 23 | fmt.Println(res, err) 24 | ---- 25 | -------------------------------------------------------------------------------- /.doc/examples/doc/acb10091ad335ddd15d71021aaf23c62.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_acb10091ad335ddd15d71021aaf23c62_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "track_scores": true, 8 | "sort": [ 9 | { 10 | "post_date": { 11 | "order": "desc" 12 | } 13 | }, 14 | { 15 | "name": "desc" 16 | }, 17 | { 18 | "age": "desc" 19 | } 20 | ], 21 | "query": { 22 | "term": { 23 | "user": "kimchy" 24 | } 25 | } 26 | }`)), 27 | es.Search.WithPretty(), 28 | ) 29 | fmt.Println(res, err) 30 | ---- 31 | -------------------------------------------------------------------------------- /.doc/examples/doc/ecc57597f6b791d1151ad79d9f4ce67b.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-datehistogram-aggregation_ecc57597f6b791d1151ad79d9f4ce67b_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "sales_over_time": { 10 | "date_histogram": { 11 | "field": "date", 12 | "calendar_interval": "1M", 13 | "format": "yyyy-MM-dd", 14 | "keyed": true 15 | } 16 | } 17 | } 18 | }`)), 19 | es.Search.WithSize(0), 20 | es.Search.WithPretty(), 21 | ) 22 | fmt.Println(res, err) 23 | ---- 24 | -------------------------------------------------------------------------------- /.doc/examples/doc/edae616e1244babf6032aecc6aaaf836.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_edae616e1244babf6032aecc6aaaf836_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "sort": [ 8 | { 9 | "_geo_distance": { 10 | "pin.location": { 11 | "lat": 40, 12 | "lon": -70 13 | }, 14 | "order": "asc", 15 | "unit": "km" 16 | } 17 | } 18 | ], 19 | "query": { 20 | "term": { 21 | "user": "kimchy" 22 | } 23 | } 24 | }`)), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | ---- 29 | -------------------------------------------------------------------------------- /.doc/typedapi/conventions/structure.asciidoc: -------------------------------------------------------------------------------- 1 | [[structure]] 2 | ==== Structure 3 | 4 | The Typed client lives in the `typedapi` package within the `go-elasticsearch` repository. 5 | 6 | The entire client is summed in an index at the root of the package for convenient access after instantiation. 7 | 8 | Each endpoint resides in its own package within `typedapi` and contains the client for this endpoint, and the `Request` struct if applicable. 9 | 10 | The requests are based on a collection of structures generated from the https://github.com/elastic/elasticsearch-specification[elasticsearch-specification] repository and gathered in a `types` package within `typedapi`. -------------------------------------------------------------------------------- /.doc/examples/doc/52fd112e970882c4d7cc4b0cca8e2c6f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-types-numeric_52fd112e970882c4d7cc4b0cca8e2c6f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "number_of_bytes": { 11 | "type": "integer" 12 | }, 13 | "time_in_seconds": { 14 | "type": "float" 15 | }, 16 | "price": { 17 | "type": "scaled_float", 18 | "scaling_factor": 100 19 | } 20 | } 21 | } 22 | }`)), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/d88e3a006208680c0a1c6974e3acecbe.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-function-score-query_d88e3a006208680c0a1c6974e3acecbe_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "function_score": { 9 | "query": { 10 | "match": { 11 | "message": "elasticsearch" 12 | } 13 | }, 14 | "script_score": { 15 | "script": { 16 | "source": "Math.log(2 + doc['likes'].value)" 17 | } 18 | } 19 | } 20 | } 21 | }`)), 22 | es.Search.WithPretty(), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/tab-widgets/update-documents.asciidoc: -------------------------------------------------------------------------------- 1 | // tag::low-level[] 2 | 3 | This is how you can update a document, for example to add a new field, by using 4 | the low-level API: 5 | 6 | [source,go] 7 | ---- 8 | client.Update("my_index", "id", strings.NewReader(`{doc: { language: "Go" }}`)) 9 | ---- 10 | 11 | // end::low-level[] 12 | 13 | 14 | // tag::fully-typed[] 15 | 16 | This is how you can update a document with the fully-typed API: 17 | 18 | [source,go] 19 | ---- 20 | typedClient.Update("my_index", "id"). 21 | Request(&update.Request{ 22 | Doc: json.RawMessage(`{ language: "Go" }`), 23 | }).Do(context.TODO()) 24 | ---- 25 | 26 | // end::fully-typed[] -------------------------------------------------------------------------------- /.doc/examples/doc/3a6238835c7d9f51e6d91f92885fadeb.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_3a6238835c7d9f51e6d91f92885fadeb_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Indices.Create( 6 | "my-index-000001", 7 | es.Indices.Create.WithBody(strings.NewReader(`{ 8 | "mappings": { 9 | "properties": { 10 | "post_date": { 11 | "type": "date" 12 | }, 13 | "user": { 14 | "type": "keyword" 15 | }, 16 | "name": { 17 | "type": "keyword" 18 | }, 19 | "age": { 20 | "type": "integer" 21 | } 22 | } 23 | } 24 | }`)), 25 | ) 26 | fmt.Println(res, err) 27 | ---- 28 | -------------------------------------------------------------------------------- /.doc/examples/doc/929d8c007ba61644537af1441f038ea6.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-metrics-valuecount-aggregation_929d8c007ba61644537af1441f038ea6_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "types_count": { 10 | "value_count": { 11 | "script": { 12 | "id": "my_script", 13 | "params": { 14 | "field": "type" 15 | } 16 | } 17 | } 18 | } 19 | } 20 | }`)), 21 | es.Search.WithSize(0), 22 | es.Search.WithPretty(), 23 | ) 24 | fmt.Println(res, err) 25 | ---- 26 | -------------------------------------------------------------------------------- /.doc/examples/doc/c4b278ba293abd0d02a0b5ad1a99f84a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_c4b278ba293abd0d02a0b5ad1a99f84a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Ingest.PutPipeline( 7 | "set-foo", 8 | strings.NewReader(`{ 9 | "description": "sets foo", 10 | "processors": [ 11 | { 12 | "set": { 13 | "field": "foo", 14 | "value": "bar" 15 | } 16 | } 17 | ] 18 | }`), 19 | ) 20 | fmt.Println(res, err) 21 | } 22 | 23 | { 24 | res, err := es.UpdateByQuery( 25 | []string{"twitter"}, 26 | es.UpdateByQuery.WithPipeline("set-foo"), 27 | ) 28 | fmt.Println(res, err) 29 | } 30 | ---- 31 | -------------------------------------------------------------------------------- /.doc/examples/doc/653c0d0ef146c997ef6bc6450d4f5f94.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_653c0d0ef146c997ef6bc6450d4f5f94_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "actors": { 9 | "terms": { 10 | "field": "actors", 11 | "size": 10 12 | }, 13 | "aggs": { 14 | "costars": { 15 | "terms": { 16 | "field": "actors", 17 | "size": 5 18 | } 19 | } 20 | } 21 | } 22 | } 23 | }`)), 24 | es.Search.WithPretty(), 25 | ) 26 | fmt.Println(res, err) 27 | ---- 28 | -------------------------------------------------------------------------------- /.doc/examples/doc/cfbaea6f0df045c5d940bbb6a9c69cd8.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_cfbaea6f0df045c5d940bbb6a9c69cd8_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "size": 0, 9 | "aggs": { 10 | "group_by_state": { 11 | "terms": { 12 | "field": "state.keyword" 13 | }, 14 | "aggs": { 15 | "average_balance": { 16 | "avg": { 17 | "field": "balance" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | }`)), 24 | es.Search.WithPretty(), 25 | ) 26 | fmt.Println(res, err) 27 | ---- 28 | -------------------------------------------------------------------------------- /.doc/examples/doc/d2d30b766e42c74a38f73252a5edc36d.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search_d2d30b766e42c74a38f73252a5edc36d_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("twitter"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "bool": { 10 | "must": { 11 | "query_string": { 12 | "query": "some query string here" 13 | } 14 | }, 15 | "filter": { 16 | "term": { 17 | "user": "kimchy" 18 | } 19 | } 20 | } 21 | } 22 | }`)), 23 | es.Search.WithRouting("kimchy"), 24 | es.Search.WithPretty(), 25 | ) 26 | fmt.Println(res, err) 27 | ---- 28 | -------------------------------------------------------------------------------- /_benchmarks/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | This folder contains code for running the [common Elasticsearch client benchmarks](https://clients-benchmarks.elastic.co). 4 | 5 | The `benchmarks` package contains the general configuration for the benchmarks. The `runner` package provides the code for running and measuring the client actions, storing the results in an Elasticsearch cluster. The individual client interactions are defined by the `actions` package. 6 | 7 | The code for setting up the benchmarks infrastructure is available at 8 | . It uses Terraform to create, setup and configure the "target" and "runner" system. 9 | 10 | -------------------------------------------------------------------------------- /.doc/examples/doc/5553cf7a02c22f616cd994747f2dd5a5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from mapping-types-nested_5553cf7a02c22f616cd994747f2dd5a5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "bool": { 10 | "must": [ 11 | { 12 | "match": { 13 | "user.first": "Alice" 14 | } 15 | }, 16 | { 17 | "match": { 18 | "user.last": "Smith" 19 | } 20 | } 21 | ] 22 | } 23 | } 24 | }`)), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | ---- 29 | -------------------------------------------------------------------------------- /.doc/examples/doc/b0eaf67e5cce24ef8889bf20951ccec1.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_b0eaf67e5cce24ef8889bf20951ccec1_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "dis_max": { 9 | "queries": [ 10 | { 11 | "match": { 12 | "subject": "brown fox" 13 | } 14 | }, 15 | { 16 | "match": { 17 | "message": "brown fox" 18 | } 19 | } 20 | ], 21 | "tie_breaker": 0.3 22 | } 23 | } 24 | }`)), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | ---- 29 | -------------------------------------------------------------------------------- /.doc/examples/doc/33f148e3d8676de6cc52f58749898a13.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from query-dsl-multi-match-query_33f148e3d8676de6cc52f58749898a13_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "dis_max": { 9 | "queries": [ 10 | { 11 | "match_phrase_prefix": { 12 | "subject": "quick brown f" 13 | } 14 | }, 15 | { 16 | "match_phrase_prefix": { 17 | "message": "quick brown f" 18 | } 19 | } 20 | ] 21 | } 22 | } 23 | }`)), 24 | es.Search.WithPretty(), 25 | ) 26 | fmt.Println(res, err) 27 | ---- 28 | -------------------------------------------------------------------------------- /.doc/examples/doc/47bb632c6091ad0cd94bc660bdd309a5.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from getting-started_47bb632c6091ad0cd94bc660bdd309a5_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("bank"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "query": { 9 | "bool": { 10 | "must": [ 11 | { 12 | "match": { 13 | "age": "40" 14 | } 15 | } 16 | ], 17 | "must_not": [ 18 | { 19 | "match": { 20 | "state": "ID" 21 | } 22 | } 23 | ] 24 | } 25 | } 26 | }`)), 27 | es.Search.WithPretty(), 28 | ) 29 | fmt.Println(res, err) 30 | ---- 31 | -------------------------------------------------------------------------------- /.ci/jobs/elastic+go-elasticsearch+pull-request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - job: 3 | name: elastic+go-elasticsearch+pull-request 4 | display-name: 'elastic / go-elasticsearch # pull-request' 5 | description: Testing the go-elasticsearch pull requests. 6 | junit_results: "*-junit.xml" 7 | scm: 8 | - git: 9 | branches: 10 | - ${ghprbActualCommit} 11 | refspec: +refs/pull/*:refs/remotes/origin/pr/* 12 | triggers: 13 | - github-pull-request: 14 | org-list: 15 | - elastic 16 | allow-whitelist-orgs-as-admins: true 17 | github-hooks: true 18 | status-context: clients-ci 19 | cancel-builds-on-update: true 20 | -------------------------------------------------------------------------------- /.doc/examples/doc/8eac28d2e9b6482b413d61817456a14f.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_8eac28d2e9b6482b413d61817456a14f_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "field": "genre", 11 | "order": { 12 | "max_play_count": "desc" 13 | } 14 | }, 15 | "aggs": { 16 | "max_play_count": { 17 | "max": { 18 | "field": "play_count" 19 | } 20 | } 21 | } 22 | } 23 | } 24 | }`)), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | ---- 29 | -------------------------------------------------------------------------------- /.doc/examples/doc/97babc8d19ef0866774576716eb6d19e.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-update-by-query_97babc8d19ef0866774576716eb6d19e_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.UpdateByQuery( 7 | []string{"test"}, 8 | es.UpdateByQuery.WithConflicts("proceed"), 9 | es.UpdateByQuery.WithRefresh(true), 10 | ) 11 | fmt.Println(res, err) 12 | } 13 | 14 | { 15 | res, err := es.Search( 16 | es.Search.WithIndex("test"), 17 | es.Search.WithBody(strings.NewReader(`{ 18 | "query": { 19 | "match": { 20 | "flag": "foo" 21 | } 22 | } 23 | }`)), 24 | es.Search.WithFilterPath("hits.total"), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | } 29 | ---- 30 | -------------------------------------------------------------------------------- /.doc/examples/doc/cd3986003382259348b84859f8ac2466.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_cd3986003382259348b84859f8ac2466_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("my-index-000001"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "sort": [ 9 | { 10 | "post_date": { 11 | "order": "asc" 12 | } 13 | }, 14 | "user", 15 | { 16 | "name": "desc" 17 | }, 18 | { 19 | "age": "desc" 20 | }, 21 | "_score" 22 | ], 23 | "query": { 24 | "term": { 25 | "user": "kimchy" 26 | } 27 | } 28 | }`)), 29 | es.Search.WithPretty(), 30 | ) 31 | fmt.Println(res, err) 32 | ---- 33 | -------------------------------------------------------------------------------- /.doc/typedapi/examples/indices.asciidoc: -------------------------------------------------------------------------------- 1 | [[indices]] 2 | ==== Creating an index 3 | 4 | For this example on how to create an index, lets create an index named `test-index` and provide a mapping for the field `price` which will be an integer. 5 | Notice how using the builder for the `IntegerNumberProperty` will automatically apply the correct value for the `type` field. 6 | 7 | [source,go] 8 | ----- 9 | res, err := es.Indices.Create("test-index"). 10 | Request(&create.Request{ 11 | Mappings: &types.TypeMapping{ 12 | Properties: map[string]types.Property{ 13 | "price": types.NewIntegerNumberProperty(), 14 | }, 15 | }, 16 | }). 17 | Do(nil) 18 | ----- 19 | -------------------------------------------------------------------------------- /.doc/examples/doc/f495f9c99916a05e3b28166d31955fad.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_f495f9c99916a05e3b28166d31955fad_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "genres": { 9 | "terms": { 10 | "field": "genre", 11 | "order": { 12 | "playback_stats.max": "desc" 13 | } 14 | }, 15 | "aggs": { 16 | "playback_stats": { 17 | "stats": { 18 | "field": "play_count" 19 | } 20 | } 21 | } 22 | } 23 | } 24 | }`)), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | ---- 29 | -------------------------------------------------------------------------------- /.doc/examples/doc/37530f35f315b9f35e3e6a13cf2a1ccd.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-terms-aggregation_37530f35f315b9f35e3e6a13cf2a1ccd_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "aggs": { 8 | "actors": { 9 | "terms": { 10 | "field": "actors", 11 | "size": 10, 12 | "collect_mode": "breadth_first" 13 | }, 14 | "aggs": { 15 | "costars": { 16 | "terms": { 17 | "field": "actors", 18 | "size": 5 19 | } 20 | } 21 | } 22 | } 23 | } 24 | }`)), 25 | es.Search.WithPretty(), 26 | ) 27 | fmt.Println(res, err) 28 | ---- 29 | -------------------------------------------------------------------------------- /.ci/Dockerfile: -------------------------------------------------------------------------------- 1 | # $ docker build --file Dockerfile --tag elastic/go-elasticsearch . 2 | # 3 | # $ docker run -it --env ELASTICSEARCH_URL=http://es1:9200 --network elasticsearch --rm elastic/go-elasticsearch go run _examples/main.go 4 | # 5 | 6 | ARG VERSION=1-alpine 7 | FROM golang:${VERSION} 8 | 9 | RUN apk add --no-cache --quiet make curl git jq unzip tree && \ 10 | go install golang.org/x/lint/golint@latest && \ 11 | go install gotest.tools/gotestsum@latest 12 | 13 | VOLUME ["/tmp"] 14 | 15 | ENV CGO_ENABLED=0 16 | ENV TERM xterm-256color 17 | 18 | WORKDIR /go-elasticsearch 19 | 20 | COPY . . 21 | 22 | RUN go mod download 23 | 24 | WORKDIR internal/cmd/generate 25 | RUN go mod download 26 | 27 | WORKDIR /go-elasticsearch -------------------------------------------------------------------------------- /.doc/examples/doc/5e0a6e903dcbef11da316fe89cf05792.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from aggregations-bucket-filter-aggregation_5e0a6e903dcbef11da316fe89cf05792_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithIndex("sales"), 7 | es.Search.WithBody(strings.NewReader(`{ 8 | "aggs": { 9 | "t_shirts": { 10 | "filter": { 11 | "term": { 12 | "type": "t-shirt" 13 | } 14 | }, 15 | "aggs": { 16 | "avg_price": { 17 | "avg": { 18 | "field": "price" 19 | } 20 | } 21 | } 22 | } 23 | } 24 | }`)), 25 | es.Search.WithSize(0), 26 | es.Search.WithPretty(), 27 | ) 28 | fmt.Println(res, err) 29 | ---- 30 | -------------------------------------------------------------------------------- /.doc/examples/doc/666c420fe61fa122386da3c356a64943.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from search-request-sort_666c420fe61fa122386da3c356a64943_test.go 2 | // 3 | [source, go] 4 | ---- 5 | res, err := es.Search( 6 | es.Search.WithBody(strings.NewReader(`{ 7 | "query": { 8 | "term": { 9 | "user": "kimchy" 10 | } 11 | }, 12 | "sort": { 13 | "_script": { 14 | "type": "number", 15 | "script": { 16 | "lang": "painless", 17 | "source": "doc['field_name'].value * params.factor", 18 | "params": { 19 | "factor": 1.1 20 | } 21 | }, 22 | "order": "asc" 23 | } 24 | } 25 | }`)), 26 | es.Search.WithPretty(), 27 | ) 28 | fmt.Println(res, err) 29 | ---- 30 | -------------------------------------------------------------------------------- /_examples/bulk/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/elastic/go-elasticsearch/v8/_examples/bulk 2 | 3 | go 1.21 4 | 5 | toolchain go1.21.8 6 | 7 | replace github.com/elastic/go-elasticsearch/v8 => ../.. 8 | 9 | require ( 10 | github.com/cenkalti/backoff/v4 v4.1.2 11 | github.com/dustin/go-humanize v1.0.0 12 | github.com/elastic/go-elasticsearch/v8 v8.0.0-20211123103400-5f8a17a2322f 13 | ) 14 | 15 | require ( 16 | github.com/elastic/elastic-transport-go/v8 v8.4.0 // indirect 17 | github.com/go-logr/logr v1.3.0 // indirect 18 | github.com/go-logr/stdr v1.2.2 // indirect 19 | go.opentelemetry.io/otel v1.21.0 // indirect 20 | go.opentelemetry.io/otel/metric v1.21.0 // indirect 21 | go.opentelemetry.io/otel/trace v1.21.0 // indirect 22 | ) 23 | -------------------------------------------------------------------------------- /.buildkite/Dockerfile: -------------------------------------------------------------------------------- 1 | # $ docker build --file Dockerfile --tag elastic/go-elasticsearch . 2 | # 3 | # $ docker run -it --env ELASTICSEARCH_URL=http://es1:9200 --network elasticsearch --rm elastic/go-elasticsearch go run _examples/main.go 4 | # 5 | 6 | ARG VERSION=1-alpine 7 | FROM golang:${VERSION} 8 | 9 | RUN apk add --no-cache --quiet make curl git jq unzip tree && \ 10 | go install golang.org/x/lint/golint@latest && \ 11 | go install gotest.tools/gotestsum@latest 12 | 13 | VOLUME ["/tmp"] 14 | 15 | ENV CGO_ENABLED=0 16 | ENV TERM xterm-256color 17 | 18 | WORKDIR /go-elasticsearch 19 | 20 | COPY . . 21 | 22 | RUN go mod download 23 | 24 | WORKDIR internal/cmd/generate 25 | RUN go mod download 26 | 27 | WORKDIR /go-elasticsearch -------------------------------------------------------------------------------- /.doc/examples/doc/9a4d5e41c52c20635d1fd9c6e13f6c7a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from docs-reindex_9a4d5e41c52c20635d1fd9c6e13f6c7a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Index( 7 | "metricbeat-2016.05.30", 8 | strings.NewReader(`{ 9 | "system.cpu.idle.pct": 0.908 10 | }`), 11 | es.Index.WithDocumentID("1"), 12 | es.Index.WithRefresh("true"), 13 | es.Index.WithPretty(), 14 | ) 15 | fmt.Println(res, err) 16 | } 17 | 18 | { 19 | res, err := es.Index( 20 | "metricbeat-2016.05.31", 21 | strings.NewReader(`{ 22 | "system.cpu.idle.pct": 0.105 23 | }`), 24 | es.Index.WithDocumentID("1"), 25 | es.Index.WithRefresh("true"), 26 | es.Index.WithPretty(), 27 | ) 28 | fmt.Println(res, err) 29 | } 30 | ---- 31 | -------------------------------------------------------------------------------- /.doc/examples/doc/ba0b4081c98f3387f76b77847c52ee9a.asciidoc: -------------------------------------------------------------------------------- 1 | // Generated from indices-update-settings_ba0b4081c98f3387f76b77847c52ee9a_test.go 2 | // 3 | [source, go] 4 | ---- 5 | { 6 | res, err := es.Indices.Close([]string{"twitter"}) 7 | fmt.Println(res, err) 8 | } 9 | 10 | { 11 | res, err := es.Indices.PutSettings(strings.NewReader(`{ 12 | "analysis": { 13 | "analyzer": { 14 | "content": { 15 | "type": "custom", 16 | "tokenizer": "whitespace" 17 | } 18 | } 19 | } 20 | }`), 21 | 22 | es.Indices.PutSettings.WithIndex([]string{"twitter"}...), 23 | ) 24 | fmt.Println(res, err) 25 | } 26 | 27 | { 28 | res, err := es.Indices.Open([]string{"twitter"}) 29 | fmt.Println(res, err) 30 | } 31 | ---- 32 | -------------------------------------------------------------------------------- /.doc/tab-widgets/connecting.asciidoc: -------------------------------------------------------------------------------- 1 | // tag::low-level[] 2 | 3 | You can connect to the Elastic Cloud using an API key and the Elasticsearch 4 | endpoint for the low level API: 5 | 6 | [source,go] 7 | ---- 8 | client, err := elasticsearch.NewClient(elasticsearch.Config{ 9 | CloudID: "", 10 | APIKey: "", 11 | }) 12 | ---- 13 | 14 | // end::low-level[] 15 | 16 | 17 | // tag::fully-typed[] 18 | 19 | You can connect to the Elastic Cloud using an API key and the Elasticsearch 20 | endpoint for the fully-typed API: 21 | 22 | [source,go] 23 | ---- 24 | typedClient, err := elasticsearch.NewTypedClient(elasticsearch.Config{ 25 | CloudID: "", 26 | APIKey: "", 27 | }) 28 | ---- 29 | 30 | // end::fully-typed[] --------------------------------------------------------------------------------