313   std::cout << 
"Content-Type:application/javascript;charset=utf-8\r\n\n";
   318     const char *queryEnv = 
getenv(
"QUERY_STRING");
   322       queryString = queryEnv;
   326       queryString = 
argv[1];
   330       std::cout << 
"No input!\n";
   335     std::vector<std::string> parts = 
split(queryString,
'&');
   340       std::vector<std::string> kv = 
split(*it,
'=');
   344         if      (kv[0]==
"q")  searchFor = 
val; 
   345         else if (kv[0]==
"n")  num       = fromString<int>(
val);
   346         else if (kv[0]==
"p")  page      = fromString<int>(
val);
   347         else if (kv[0]==
"cb") callback  = 
val;
   353     if (queryString==
"test") 
   358         std::cout << 
"Test successful.";
   362         std::cout << 
"Test failed: cannot find search index " << indexDir;
   369     Xapian::Enquire enquire(db);
   371     std::vector<std::string> words = 
split(searchFor,
' ');
   374       query = Xapian::Query(Xapian::Query::OP_OR,query,Xapian::Query(*it));
   376     enquire.set_query(query);
   379     Xapian::MSet 
matches = enquire.get_mset(page*num,num);
   380     unsigned int hits    = matches.get_matches_estimated();
   381     unsigned int offset  = page*
num;
   382     unsigned int pages   = num>0 ? (hits+num-1)/num : 0;
   383     if (offset>hits)     offset=hits;
   384     if (offset+num>hits) num=hits-offset;
   387     std::cout << callback.c_str() << 
"(";
   389               << 
"  \"hits\":"   << hits   << 
"," << 
std::endl   390               << 
"  \"first\":"  << offset << 
"," << 
std::endl   391               << 
"  \"count\":"  << num    << 
"," << 
std::endl   392               << 
"  \"page\":"   << page   << 
"," << 
std::endl   393               << 
"  \"pages\":"  << pages  << 
"," << 
std::endl   397     unsigned int o = offset;
   398     for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i,++o) 
   400       std::vector<Fragment> hl;
   401       Xapian::Document 
doc = i.get_document();
   403       std::cout << 
"  {\"type\": \"" << doc.get_value(
FIELD_TYPE) << 
"\"," << std::endl
   405                 << 
"   \"tag\": \""  << doc.get_value(
FIELD_TAG) << 
"\"," << std::endl
   407       std::cout << 
"   \"fragments\":[" << 
std::endl;
   412         if (!first) std::cout << 
"," << 
std::endl;
   419       if (o<offset+num-1) std::cout << 
",";
   422     std::cout << 
" ]" << std::endl << 
"})" << 
std::endl;
   430     showError(callback,
"Unknown Exception!");
 static std::string escapeString(const std::string &s)
static void highlighter(const std::string &s, const std::vector< std::string > &words, std::vector< Fragment > &fragments)
static std::string uriDecode(const std::string &sSrc)
nvidia::inferenceserver::client::Error Error
std::string getenv(std::string const &name)
static std::vector< std::string > split(const std::string &s, char delim)
static void showError(const std::string &callback, const std::string &error)
bool dirExists(const std::string &dirName)
query_result< Args... > query(sqlite3 *db, std::string const &ddl)
QTextStream & endl(QTextStream &s)