@@ -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,34 @@ 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
+ // / Delete given type (and all documents, mappings)
313
+ bool ElasticSearch::deleteType (const std::string& index, const std::string& type){
314
+ std::ostringstream uri;
315
+ uri << index << " /" << type;
316
+ return (200 == _http.remove (uri.str ().c_str (), 0 , 0 ));
317
+ }
318
+
319
+ // Test if index exists
320
+ bool ElasticSearch::exist (const std::string& index){
321
+ return (200 == _http.head (index.c_str (), 0 , 0 ));
322
+ }
323
+
324
+ // Create index, optionally with data (settings, mappings etc)
325
+ bool ElasticSearch::createIndex (const std::string& index, const char * data){
326
+ return (200 == _http.put (index.c_str (), data, 0 ));
327
+ }
328
+
329
+ // Delete given index (and all types, documents, mappings)
330
+ bool ElasticSearch::deleteIndex (const std::string& index){
331
+ return (200 == _http.remove (index.c_str (), 0 , 0 ));
332
+ }
333
+
334
+ // Refresh the index.
335
+ void ElasticSearch::refresh (const std::string& index){
336
+ std::ostringstream oss;
337
+ oss << index << " /_refresh" ;
338
+
339
+ Json::Object msg;
340
+ _http.get (oss.str ().c_str (), 0 , &msg);
341
+ }
0 commit comments