本文整理汇总了C++中SearchEngineInterface::setDefaultOperator方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchEngineInterface::setDefaultOperator方法的具体用法?C++ SearchEngineInterface::setDefaultOperator怎么用?C++ SearchEngineInterface::setDefaultOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchEngineInterface
的用法示例。
在下文中一共展示了SearchEngineInterface::setDefaultOperator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runQuery
bool DBusServletThread::runQuery(QueryProperties &queryProps, vector<string> &docIds)
{
PinotSettings &settings = PinotSettings::getInstance();
docIds.clear();
SearchEngineInterface *pEngine = ModuleFactory::getSearchEngine(settings.m_defaultBackend,
settings.m_daemonIndexLocation);
if (pEngine == NULL)
{
return false;
}
// Run the query
pEngine->setDefaultOperator(SearchEngineInterface::DEFAULT_OP_AND);
if (pEngine->runQuery(queryProps) == false)
{
delete pEngine;
return false;
}
const vector<DocumentInfo> &resultsList = pEngine->getResults();
if (resultsList.empty() == true)
{
#ifdef DEBUG
cout << "DBusServletThread::runQuery: trying again" << endl;
#endif
// Try again, this time with OR as default operator
pEngine->setDefaultOperator(SearchEngineInterface::DEFAULT_OP_OR);
if (pEngine->runQuery(queryProps) == false)
{
delete pEngine;
return false;
}
}
for (vector<DocumentInfo>::const_iterator resultIter = resultsList.begin();
resultIter != resultsList.end(); ++resultIter)
{
unsigned int indexId = 0;
unsigned int docId = resultIter->getIsIndexed(indexId);
// We only need the document ID
if (docId > 0)
{
char docIdStr[64];
snprintf(docIdStr, 64, "%u", docId);
docIds.push_back(docIdStr);
}
}
delete pEngine;
return true;
}
示例2: doWork
void ExpandQueryThread::doWork(void)
{
// Get the SearchEngine
SearchEngineInterface *pEngine = SearchEngineFactory::getSearchEngine("xapian", "MERGED");
if (pEngine == NULL)
{
m_errorNum = UNKNOWN_ENGINE;
m_errorParam = m_queryProps.getName();
return;
}
// Expand the query
pEngine->setExpandSet(m_expandFromDocsSet);
// Run the query
pEngine->setDefaultOperator(SearchEngineInterface::DEFAULT_OP_AND);
if (pEngine->runQuery(m_queryProps) == false)
{
m_errorNum = QUERY_FAILED;
}
else
{
// Copy the expand terms
const set<string> &expandTerms = pEngine->getExpandTerms();
copy(expandTerms.begin(), expandTerms.end(),
inserter(m_expandTerms, m_expandTerms.begin()));
}
delete pEngine;
}
示例3: doWork
void ExpandQueryThread::doWork(void)
{
IndexInterface *pIndex = PinotSettings::getInstance().getIndex("MERGED");
set<unsigned int> relevantDocIds;
if ((pIndex == NULL) ||
(pIndex->isGood() == false))
{
m_status = _("Index error on");
m_status += " MERGED";
if (pIndex != NULL)
{
delete pIndex;
}
return;
}
for (set<string>::iterator locationIter = m_relevantDocs.begin();
locationIter != m_relevantDocs.end(); ++locationIter)
{
relevantDocIds.insert(pIndex->hasDocument(*locationIter));
}
delete pIndex;
// Get the SearchEngine
SearchEngineInterface *pEngine = SearchEngineFactory::getSearchEngine("xapian", "MERGED");
if (pEngine == NULL)
{
m_status = _("Couldn't create search engine");
m_status += " ";
m_status += m_queryProps.getName();
return;
}
// Set whether to expand the query
pEngine->setQueryExpansion(relevantDocIds);
// Run the query
pEngine->setDefaultOperator(SearchEngineInterface::DEFAULT_OP_AND);
if (pEngine->runQuery(m_queryProps) == false)
{
m_status = _("Couldn't run query on search engine");
}
else
{
// Copy the expand terms
const set<string> &expandTerms = pEngine->getExpandTerms();
copy(expandTerms.begin(), expandTerms.end(),
inserter(m_expandTerms, m_expandTerms.begin()));
}
delete pEngine;
}
示例4: main
//.........这里部分代码省略.........
// Which SearchEngine ?
SearchEngineInterface *pEngine = ModuleFactory::getSearchEngine(engineType, option);
if (pEngine == NULL)
{
clog << "Couldn't obtain search engine instance" << endl;
DownloaderInterface::shutdown();
MIMEScanner::shutdown();
return EXIT_FAILURE;
}
// Set up the proxy
WebEngine *pWebEngine = dynamic_cast<WebEngine *>(pEngine);
if (pWebEngine != NULL)
{
DownloaderInterface *pDownloader = pWebEngine->getDownloader();
if ((pDownloader != NULL) &&
(settings.m_proxyEnabled == true) &&
(settings.m_proxyAddress.empty() == false))
{
char portStr[64];
pDownloader->setSetting("proxyaddress", settings.m_proxyAddress);
snprintf(portStr, 64, "%u", settings.m_proxyPort);
pDownloader->setSetting("proxyport", portStr);
pDownloader->setSetting("proxytype", settings.m_proxyType);
}
pWebEngine->setEditableValues(settings.m_editablePluginValues);
}
pEngine->setDefaultOperator(SearchEngineInterface::DEFAULT_OP_AND);
if (pEngine->runQuery(queryProps) == true)
{
string resultsPage;
unsigned int estimatedResultsCount = pEngine->getResultsCountEstimate();
const vector<DocumentInfo> &resultsList = pEngine->getResults();
if (resultsList.empty() == false)
{
if (printResults == true)
{
unsigned int count = 0;
if (locationOnly == false)
{
clog << "Showing " << resultsList.size() << " results of about " << estimatedResultsCount << endl;
}
vector<DocumentInfo>::const_iterator resultIter = resultsList.begin();
while (resultIter != resultsList.end())
{
string rawUrl(resultIter->getLocation(true));
if (locationOnly == false)
{
clog << count << " Location : '" << rawUrl << "'"<< endl;
clog << count << " Title : " << resultIter->getTitle() << endl;
clog << count << " Type : " << resultIter->getType() << endl;
clog << count << " Language : " << resultIter->getLanguage() << endl;
clog << count << " Date : " << resultIter->getTimestamp() << endl;
clog << count << " Size : " << resultIter->getSize() << endl;
clog << count << " Extract : " << resultIter->getExtract() << endl;
clog << count << " Score : " << resultIter->getScore() << endl;