-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
67 lines (53 loc) · 1.32 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <curl/curl.h>
#include <string>
#include "Client.h"
#include "utilities/environment.h"
#include "utilities/utilFunctions.h"
#include "utilities/configfileHandler.h"
#include <simdjson/simdjson.h>
#include "utilities/querybuilder/searchQuery.h"
#include <nlohmann/json.hpp>
/**
* Only used for testing the library.
*
*/
int main() {
utils::initEsClient();
simdjson::ondemand::parser parser;
int indent = 4;
// Configuration config;
// config.loadConfigfile();
const std::string HOST = "localhost";
const int PORT = 9200;
CURLcode res{};
Client client{HOST, PORT};
client.verboseLogging(1L);
Search search{};
std::string body = search.matchQuery("name", "test")->buildQuery();
auto finalRes = client.search("miguel", body);
nlohmann::json j = nlohmann::json::parse(client.getReadBuffer());
std::cout << "Response from ES: " << j.dump(indent) << std::endl;
utils::responseCheck(finalRes);
utils::cleanUpEsClient();
return 0;
}
/*
* Lets say I have the following class:
```c++
class Text {
private:
std::string content;
std::string title;
public:
void add_content();
void add_title();
}
```
And I have the following implementation:
```c++
void Text::add_content(std::string content) {
this->content.append(content);
}
```
*/