@@ -16,15 +16,6 @@ ElasticSearch::ElasticSearch(const std::string& node, bool readOnly): _http(node
16
16
ElasticSearch::~ElasticSearch () {
17
17
}
18
18
19
- // Refresh the index.
20
- void ElasticSearch::refresh (const std::string& index){
21
- std::ostringstream oss;
22
- oss << index << " /_refresh" ;
23
-
24
- Json::Object msg;
25
- _http.get (oss.str ().c_str (), 0 , &msg);
26
- }
27
-
28
19
// Test connection with node.
29
20
bool ElasticSearch::isActive () {
30
21
@@ -162,11 +153,6 @@ long unsigned int ElasticSearch::getDocumentCount(const char* index, const char*
162
153
return pos;
163
154
}
164
155
165
- // Test if index exists
166
- bool ElasticSearch::exist (const std::string& index){
167
- return (200 == _http.head (index.c_str (), 0 , 0 ));
168
- }
169
-
170
156
// Test if document exists
171
157
bool ElasticSearch::exist (const std::string& index, const std::string& type, const std::string& id){
172
158
std::stringstream url;
@@ -322,3 +308,22 @@ long ElasticSearch::search(const std::string& index, const std::string& type, co
322
308
323
309
return result.getValue (" hits" ).getObject ().getValue (" total" ).getLong ();
324
310
}
311
+
312
+ // Test if index exists
313
+ bool ElasticSearch::exist (const std::string& index){
314
+ return (200 == _http.head (index.c_str (), 0 , 0 ));
315
+ }
316
+
317
+ // Test if index exists
318
+ bool ElasticSearch::createIndex (const std::string& index, const char * data){
319
+ return (200 == _http.put (index.c_str (), data, 0 ));
320
+ }
321
+
322
+ // Refresh the index.
323
+ void ElasticSearch::refresh (const std::string& index){
324
+ std::ostringstream oss;
325
+ oss << index << " /_refresh" ;
326
+
327
+ Json::Object msg;
328
+ _http.get (oss.str ().c_str (), 0 , &msg);
329
+ }
0 commit comments