Skip to content

C++ Interface to ElasticSearch to PUT, POST, GET and more.

License

Notifications You must be signed in to change notification settings

bastianhjaeger/elasticpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

General

ElastiCpp-Release ElastiCpp-Debug

Interface to manipulate elasticsearch by REST API from c++.

Installation

git clone [email protected]:bastianhjaeger/elasticpp.git
cd elasticpp
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j8
sudo make install

Usage

plain functions

#include <elasticpp/elasticpp.h>

const bool singleCall = true;
const bool verbose = true;

const std::string sResponse 
    = elastic_cpp("http://localhost:9200/test", "", "", PUT, singleCall, verbose);
const json jResponse 
    = elastic_cpp("http://localhost:9200/test", "", json(), PUT);

class implementation

#include <elasticpp/ElastiCpp.h>

const int verbose = 0;
const int shards = 1;
const int replicas = 1;
const std::string url = "test_index";

ElastiCpp ec("http://localhost:9200/", "user:password");

bool success = ec.createIndex(url, shards, replicas, verbose);

const json response = ec.getIndex(url, verbose);
std::cout << "response: " << response.dump(3) << std::endl;

success = ec.deleteIndex(url, verbose);

// or any randon message/query
const json response2 = ec.send("index_*/_search", R"({"query": {"match_all": {}}})");

Othres

Thanks to JSON for Modern C++ (version 3.7.2) https://github.com/nlohmann/json

About

C++ Interface to ElasticSearch to PUT, POST, GET and more.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages