void ExpandQueryThread::doWork(void) { // Get the SearchEngine SearchEngineInterface *pEngine = SearchEngineFactory::getSearchEngine(m_engineName, m_engineOption); if (pEngine == NULL) { m_status = _("Couldn't create search engine"); m_status += " "; m_status += m_queryProps.getName(); return; } // Set the maximum number of results pEngine->setMaxResultsCount(m_queryProps.getMaximumResultsCount()); // Set whether to expand the query pEngine->setQueryExpansion(m_relevantDocs); // Run the query if (pEngine->runQuery(m_queryProps) == false) { m_status = _("Couldn't run query on search engine"); m_status += " "; m_status += m_engineName; } else { // Copy the expand terms const set<string> &expandTerms = pEngine->getExpandTerms(); copy(expandTerms.begin(), expandTerms.end(), inserter(m_expandTerms, m_expandTerms.begin())); } delete pEngine; }
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 the maximum number of results pEngine->setMaxResultsCount(m_queryProps.getMaximumResultsCount()); // Set whether to expand the query pEngine->setQueryExpansion(relevantDocIds); // Run the query 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; }