---------------------- "; string hlend= ""; query_string= "q="; query_string.append(argv1); qsnonp_urlencoded= query_string.regex_cut("(^|&)(np=[^&]*)"); // Create ENV.UDM_TEST_DIR // TODO: change indexer.conf syntax to use getenv() tmp= "ReplaceVar ENV.UDM_TEST_DIR "; tmp.append(testdir); if (env.addline(tmp)) { cout << tmp << '\n'; cout << "addline() failed: " << env.errmsg() << '\n'; exit(0); } tmp= "ReplaceVar ENV.UDM_TEST_DBADDR0 "; tmp.append(dbaddr0); if (env.addline(tmp)) { cout << tmp << '\n'; cout << "addline() failed: " << env.errmsg() << '\n'; exit(0); } if (dbaddr1.length()) { tmp= "ReplaceVar ENV.UDM_TEST_DBADDR1 "; tmp.append(dbaddr1); if (env.addline(tmp)) { cout << tmp << '\n'; cout << "addline() failed: " << env.errmsg() << '\n'; exit(0); } } tmp= query_string.regex_substr("(^|&)(wf0)=([^&]*)", "ReplaceVar $2 $3"); if (tmp.length()) { if (env.addline(tmp)) { cout << tmp << '\n'; cout << "addline() failed: " << env.errmsg() << '\n'; exit(0); } } tmp= query_string.regex_substr("(^|&)(wf1)=([^&]*)", "ReplaceVar $2 $3"); if (tmp.length()) { if (env.addline(tmp)) { cout << tmp << '\n'; cout << "addline() failed: " << env.errmsg() << '\n'; exit(0); } } tmp= query_string.regex_substr("(^|&)(MaxResults0)=([^&]*)", "ReplaceVar $2 $3"); if (tmp.length()) { if (env.addline(tmp)) { cout << tmp << '\n'; cout << "addline() failed: " << env.errmsg() << '\n'; exit(0); } } tmp= query_string.regex_substr("(^|&)(MaxResults1)=([^&]*)", "ReplaceVar $2 $3"); if (tmp.length()) { if (env.addline(tmp)) { cout << tmp << '\n'; cout << "addline() failed: " << env.errmsg() << '\n'; exit(0); } } tmp= query_string.regex_substr("(^|&)(SetQueryCacheID)=([^&]*)", "$2"); if (!tmp.compare("")) env.addline("ReplaceVar QueryCacheID '${q}.${pqid}.${SearchMode}.${orig_m}.${fl}.${wm}.${o}.${t}.${cat}.${ul}.${wf}.${g}.${GroupBySite}.${site}.${type}.${sp}.${sy}.${dt}.${dp}.${dx}.${dm}.${dy}.${db}.${de}.${s}.${sl.*}'"); // Include search.conf file from the current test directory, if exists include.append(testdir); tmp= query_string.regex_substr("(^|&)localconf=([^&]*)", "$2"); if (tmp.compare("")) { include.append("/"); include.append(tmp); } else { include.append("/search.conf"); } if (env.addline(include)) { tmp= env.errmsg(); tmp= tmp.substr(0, 10); if (tmp.compare("Can't open")) { cout << env.errmsg() << '\n'; exit(0); } } tmp= env.property("ResFormatDisplayQueryString"); if (tmp.compare("no")) cout << "QUERY_STRING=" << query_string << '\n'; else cout << "QUERY_STRING=[DISALLOWED]" << '\n'; // Define DBAddr tmp= env.property("AutoDBAddr"); if (tmp.compare("no")) { dbaddr.append(dbaddr0); dbaddr.append("?SetNames=latin1"); tmp= env.property("DBMode"); if (tmp.length()) { dbaddr.append("&dbmode="); dbaddr.append(tmp); } else { tmp= query_string.regex_substr("(^|&)dbmode=([^&]*)", "$2"); if (tmp.length()) { dbaddr.append("&dbmode="); dbaddr.append(tmp); } else dbaddr.append("&dbmode=blob"); } tmp= query_string.regex_substr("(^|&)LiveUpdates=([^&]*)", "$2"); if (tmp.length()) { dbaddr.append("&LiveUpdates="); dbaddr.append(tmp); } dbaddr.append(param); env.addline(dbaddr); //cout << "DBADDR:" << dbaddr << '\n'; } // Frequently used parameters that tests pass in query string lcs= query_string.regex_substr("(^|&)lcs=([^&]*)", "$2"); if (lcs.length()) { string line= "LocalCharset "; line.append(lcs); env.addline(line); } bcs= query_string.regex_substr("(^|&)bcs=([^&]*)", "$2"); if (bcs.length()) { string line= "BrowserCharset "; line.append(bcs); env.addline(line); } tmp= query_string.regex_substr("(^|&)CaseFolding=([^&]*)", "$2"); if (tmp.length()) { string line= "CaseFolding "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)MinWordLength=([^&]*)", "$2"); if (tmp.length()) { string line= "MinWordLength "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)dh=([^&]*)", "$2"); if (tmp.length()) { string line= "Dehyphenate "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)sss=([^&]*)", "$2"); if (tmp.length()) { string line= "SaveSectionSize "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)macf=([^&]*)", "$2"); if (tmp.length()) { string line= "MaxCoordFactor "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)wdf=([^&]*)", "$2"); if (tmp.length()) { string line= "WordDensityFactor "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)wdw=([^&]*)", "$2"); if (tmp.length()) { string line= "WordDistanceWeight "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)wfw=([^&]*)", "$2"); if (tmp.length()) { string line= "WordFormFactor "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)smmwl=([^&]*)", "$2"); if (tmp.length()) { string line= "SubstringMatchMinWordLength "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)csyn=([^&]*)", "$2"); if (tmp.length()) { string line= "ComplexSynonyms "; line.append(tmp); env.addline(line); } tmp= query_string.regex_substr("(^|&)DateFactor=([^&]*)", "$2"); if (tmp.length()) { string line= "DateFactor "; line.append(tmp); env.addline(line); } get_cc= query_string.regex_substr("(^|&)cc=([^&]*)", "$2"); if (get_cc.length()) { DOCUMENT doc; string URL; doc.cached(env, query_string); URL= doc.property("URL"); ?> URL: Size: Content-Type: Charset: LocalCharset: BrowserCharset: Document: 0) { cout << "Too few results were found in strict mode: " << StrictModeFound << '\n'; cout << "Displaying results in less strict mode." << '\n'; } // Search result summary if (res.num_rows()) { cout << "Displaying documents " << res.first() + 1 << "-" << res.last() + 1 << " of " << res.total_found() << '\n'; } // Segmented query string // TODO: change this to res.property("SEGMENTER.QUERY_STRING") tmp= env.property("SEGMENTER.QUERY_STRING"); if (tmp.compare("")) cout << "Segmenter: " << env.property("SEGMENTER.QUERY_STRING") << '\n'; // Standard word statistics (all word forms without groupping) cout << "Search results: "; for (int i= 0; i < res.num_words(); i++) { QUERYWORD qword= res.word(i); string word= qword.word(); if (i > 0) cout << ", "; if (qword.origin() == 5) cout << word.htmlencode() << ": stopword"; else if (qword.origin() == 6) ; // Suggestion, do nothing else cout << word.htmlencode() << ": " << qword.count(); } cout << '\n' << '\n'; // Extended word statistics tmp= env.property("DisplayWordDetails"); if (!tmp.compare("yes")) { cout << "nwords=" << res.num_words() << '\n'; for (int i= 0; i < res.num_words(); i++) { QUERYWORD qword= res.word(i); cout << "word" << i << ":"; cout << " word='" << qword.word() << "'"; cout << " count=" << qword.count(); cout << " doccount=" << qword.doccount(); cout << " order=" << qword.order(); cout << " origin=" << qword.origin(); cout << " weight=" << qword.weight(); cout << '\n'; } cout << '\n'; } // Document information for (int i= 0; i < res.num_rows(); i++) { string fmt; cout << res.document_property_html(i, "order") << ". "; cout << "["; cout << res.document_property_html(i, "score"); cout << "] "; tmp= res.document_property_html(i, "Alias"); if (tmp.compare("")) cout << tmp; else cout << res.document_property_html(i, "url"); tmp= env.property("DisplayPopularity"); if (!tmp.compare("yes")) { cout << " [Popularity:"; cout << res.document_property_html(i, "Pop_Rank"); cout << "] "; } fmt= env.property("ResFormat"); if (!fmt.compare("long")) { cout << '\n'; tmp= env.property("ResFormatDisplayID"); if (!tmp.compare("yes")) cout << "ID: " << res.document_property_html(i, "ID") << '\n'; tmp= env.property("ResFormatLongDisplayStatus"); if (!tmp.compare("yes")) cout << "Status: " << res.document_property(i, "Status") << '\n'; tmp= env.property("ResFormatDisplayCachedURL"); if (!tmp.compare("yes")) cout << "Cached URL: " << res.document_property_html(i, "stored_href") << '\n'; cout << "Title: " << res.document_property_html(i, "title", hlbeg, hlend) << '\n'; tmp= res.document_property_html(i, "msg.subject", hlbeg, hlend); if (tmp.compare("")) cout << "MSG.Subject: " << tmp << '\n'; cout << "Body: " << res.document_property_html(i, "body", hlbeg, hlend) << '\n'; tmp= res.document_property_html(i, "meta.og:description", hlbeg, hlend); if (tmp.compare("")) cout << "META:OG:DESCRIPTION: " << tmp << '\n'; tmp= env.property("ResFormatLongEnableTimestamp"); if (!tmp.compare("yes")) cout << "Modified: " << res.document_property_html(i, "Last-Modified-Timestamp", hlbeg, hlend) << '\n'; cout << "Content-Length: " << res.document_property_html(i, "Content-Length", hlbeg, hlend) << '\n'; cout << "Content-Type: " << res.document_property_html(i, "Content-Type", hlbeg, hlend) << '\n'; tmp= env.property("ResFormatLongDisplayCharset"); if (!tmp.compare("yes")) cout << "Charset: " << res.document_property_html(i, "Charset", hlbeg, hlend) << '\n'; tmp= env.property("ResFormatLongDisplayLastModified"); if (!tmp.compare("yes")) cout << "Last-Modified: " << res.document_property_html(i, "Last-Modified", hlbeg, hlend) << '\n'; tmp= res.document_property_html(i, "meta.keywords", hlbeg, hlend); if (tmp.compare("")) cout << "Keywords: " << tmp << '\n'; tmp= res.document_property_html(i, "tag", hlbeg, hlend); if (tmp.compare("")) cout << "Tag: " << tmp << '\n'; tmp= res.document_property_html(i, "image", hlbeg, hlend); if (tmp.compare("")) cout << "Image: " << tmp << '\n'; // test-parsexml specific sections tmp= res.document_property_html(i, "/xxx/yyy/zzz", hlbeg, hlend); if (tmp.compare("")) cout << "/xxx/yyy/zzz: " << tmp << '\n'; tmp= res.document_property_html(i, "/xxx/a/_underscore", hlbeg, hlend); if (tmp.compare("")) cout << "/xxx/a/_underscore: " << tmp << '\n'; tmp= res.document_property_html(i, "/xxx/b/colon:a.b-c", hlbeg, hlend); if (tmp.compare("")) cout << "/xxx/b/colon:a.b-c: " << tmp << '\n'; tmp= res.document_property(i, "PerSite"); if (tmp.stoi() > 0) { string url= res.document_property(i, "url"); string sitelimit= url.regex_cut("^[a-z]*://[^/]*/(.*)"); string sitename; cout << "More results from this site: " << tmp.stoi() << '\n'; cout << "Site limit URL: " << qsnonp_urlencoded << "&site=" << sitelimit.urlencode() << '\n'; } tmp= env.property("ResFormatLongDisplayWordSectionHit"); if (!tmp.compare("yes")) { cout << "UniqueWordHitFlags: " << res.document_property(i, "UniqueWordHitFlags") << '\n'; cout << "UniqueWordHitVector: " << res.document_property(i, "UniqueWordHitVector") << '\n'; cout << "SectionHitVector: " << res.document_property(i, "SectionHitVector") << '\n'; } tmp= res.document_property(i, "nclones"); if (tmp.stoi()) { cout << "nclones: " << tmp << '\n'; for (int clone= 0; clone < tmp.stoi(); clone++) { string prefix= "Clone"; string idx= to_string(clone); string tmpname; prefix.append(idx); prefix.append("."); tmpname= prefix; tmpname.append("URL"); cout << " " << tmpname << "=" << res.document_property(i, tmpname) << '\n'; tmpname= prefix; tmpname.append("Alias"); cout << " " << tmpname << "=" << res.document_property(i, tmpname) << '\n'; tmpname= prefix; tmpname.append("Content-Length"); cout << " " << tmpname << "=" << res.document_property(i, tmpname) << '\n'; } } cout << '\n'; } else { cout << " "; cout << res.document_property_html(i, "body", hlbeg, hlend); cout << '\n'; } tmp= env.property("ResFormatIncludeURL"); if (tmp.length()) { DOCUMENT inc; int rc= inc.download(env, tmp); cout << "rc=" << rc << '\n'; cout << "############### Start of included file ################" << '\n'; cout << inc.content() << '\n'; cout << "############### End of included file ################" << '\n'; } } if (!res.num_rows()) { string ws= res.property("WS"); cout << "Sorry, your search did not find any results" << '\n'; if (ws.length()) { cout << "Did you mean " << ws.htmlencode() << "?" << '\n'; } } ?>