C++ elasticlient library is simple library for simplified work with Elasticsearch in C++.
You can find some basic information - how to build library and how to use it in Readme.md file.
Provided features
Major provided classes
Helper functions
Helper enumerations
How to use the library
#include <string>
#include <vector>
#include <iostream>
#include <cpr/response.h>
int main() {
std::string document {"{\"message\": \"Hello world!\"}"};
cpr::Response indexResponse = client.
index(
"testindex",
"docType",
"docId", document);
std::cout << indexResponse.status_code << std::endl;
std::cout << indexResponse.header["content-type"] << std::endl;
std::cout << indexResponse.text << std::endl;
cpr::Response retrievedDocument = client.get("testindex", "docType", "docId");
std::cout << retrievedDocument.status_code << std::endl;
std::cout << retrievedDocument.header["content-type"] << std::endl;
std::cout << retrievedDocument.text << std::endl;
cpr::Response removedDocument = client.remove("testindex", "docType", "docId");
std::cout << removedDocument.status_code << std::endl;
std::cout << removedDocument.header["content-type"] << std::endl;
std::cout << removedDocument.text << std::endl;
return 0;
}
You can also find this and more examples of basic usage of library here.
Templated version of the constructor elasticlient::Client::Client accepts option arguments to set timeout, proxy servers or SSL. Just pass these instances to it in any order (just after vector of cluster nodes):