@@ -357,6 +357,53 @@ int dump_mappings(
357
357
return 0 ;
358
358
}
359
359
360
+ int dump_index_info (
361
+ std::string const & host,
362
+ std::string const & index,
363
+ auth_options const & auth)
364
+ {
365
+ static char write_buffer[WRITE_BUF_SIZE];
366
+ static rapidjson::FileWriteStream stream (stdout, write_buffer, sizeof (write_buffer));
367
+
368
+ CURL * crl = curl_easy_init ();
369
+ long response_code;
370
+ rapidjson::Document doc;
371
+ std::string url = host + " /" + index;
372
+ std::string error;
373
+ std::vector<char > buffer;
374
+
375
+ bool res = get_or_post_data (
376
+ crl,
377
+ url,
378
+ auth,
379
+ &buffer,
380
+ &response_code,
381
+ &error);
382
+
383
+ if (!res)
384
+ {
385
+ std::cerr << " A HTTP error occured: " << error << std::endl;
386
+ return 1 ;
387
+ }
388
+
389
+ doc.Parse (buffer.data (), buffer.size ());
390
+
391
+ if (doc.HasParseError ())
392
+ {
393
+ output_parser_error (doc, std::cerr);
394
+ return 1 ;
395
+ }
396
+
397
+ rapidjson::Writer<rapidjson::FileWriteStream> writer (stream);
398
+ doc[index.c_str ()].Accept (writer);
399
+ stream.Put (' \n ' );
400
+ stream.Flush ();
401
+
402
+ curl_easy_cleanup (crl);
403
+
404
+ return 0 ;
405
+ }
406
+
360
407
int main (
361
408
int argc,
362
409
char * argv[])
@@ -411,6 +458,13 @@ int main(
411
458
index,
412
459
auth);
413
460
}
461
+ else if (cmdl[" --dump-index-info" ])
462
+ {
463
+ return dump_index_info (
464
+ host,
465
+ index,
466
+ auth);
467
+ }
414
468
415
469
// Sanity check - see if we have any documents in the index at all.
416
470
if (count_documents (host, index, auth) <= 0 )
0 commit comments