void put(SerialNum serialNum, const search::DocumentIdT lid) { iw.put(serialNum, *dummyDoc, lid); iw.commit(serialNum, std::shared_ptr<IDestructorCallback>()); }
void remove(SerialNum serialNum, const search::DocumentIdT lid) { iw.remove(serialNum, lid); iw.commit(serialNum, std::shared_ptr<IDestructorCallback>()); }
/* int xesamquery(int argc, char** argv) { // parse arguments parseArguments(argc, argv); string backend = options['t']; string indexdir = options['d']; string ulfile = options['u']; string qlfile = options['q']; // check arguments: indexdir if (indexdir.length() == 0) { pe("Provide the directory with the index.\n"); return usage(argc, argv); } if ((ulfile.length() == 0) && (qlfile.length() == 0)) { pe ("Provide at last one file containing the xesam query formulated "); pe ("with query language or user language.\n"); return usage(argc, argv); } if (arguments.size() != 0) { pe("You do not have to provide other arguments.\n"); return usage(argc, argv); return 1; } Xesam2Strigi xesam2strigi; if (qlfile.length() != 0) { printf ("processing xesam querylanguage query from file %s\n", qlfile.c_str()); if (xesam2strigi.parse_file ( qlfile, Xesam2Strigi::QueryLanguage)) printf ("Xesam query parsed successfully\n"); else { pe ("error parsing query\n"); return 1; } } else if (ulfile.length() != 0) { printf ("processing xesam userlanguage query from file %s\n", ulfile.c_str()); if (xesam2strigi.parse_file ( ulfile, Xesam2Strigi::UserLanguage)) printf ("Xesam query parsed successfully\n"); else { pe ("error parsing query\n"); return 1; } } // create an index manager IndexManager* manager = getIndexManager(backend, indexdir); if (manager == 0) { return usage(argc, argv); } IndexReader* reader = manager->indexReader(); unsigned int results = 0; const uint batchsize = 10; Query query = xesam2strigi.query(); vector<IndexedDocument> matches = reader->query(query, 0, batchsize); if (matches.size() != 0) { printf ("Search results:\n"); } else { printf ("No results for search\n"); } while (matches.size() > 0) { for (vector<IndexedDocument>::iterator it = matches.begin(); it != matches.end(); ++it) { printf ("\"%s\" matched\n", it->uri.c_str()); printIndexedDocument(*it); } results += (int)matches.size(); if (matches.size() == batchsize) { // maybe there're other results matches = reader->query(query, results + 1, 10); } else { matches.clear(); // force while() exit } } if (results != 0) printf ("Query returned %i results\n", results); IndexPluginLoader::deleteIndexManager(manager); return 0; } */ int deindex(int argc, char** argv) { // parse arguments parseArguments(argc, argv); string backend = options['t']; string indexdir = options['d']; // check arguments: indexdir if (indexdir.length() == 0) { pe("Provide the directory with the index.\n"); return usage(argc, argv); } // check arguments: dirs if (arguments.size() == 0) { pe("'%s' '%s'\n", backend.c_str(), indexdir.c_str()); pe("Provide directories/files to deindex.\n"); return usage(argc, argv); } AnalyzerConfiguration config; // create an index manager IndexManager* manager = getIndexManager(backend, indexdir); if (manager == 0) { return usage(argc, argv); } // retrieve all indexed files at level 0 (archives contents aren't returned) map<string, time_t> indexedFiles; /* TODO: make this code not use indexReader->files(0) IndexReader* indexReader = manager->indexReader(); indexedFiles = indexReader->files(0); */ vector<string> toDelete; for (vector<string>::iterator iter = arguments.begin(); iter != arguments.end(); ++iter) { // find all indexed files whose path starts with *iter FindIndexedFiles match (*iter); map<string, time_t>::iterator itBeg, itEnd, itMatch; itBeg = indexedFiles.begin(); itEnd = indexedFiles.end(); itMatch = find_if (itBeg, itEnd, match); while (itMatch != itEnd) { toDelete.push_back (itMatch->first); itBeg = ++itMatch; itMatch = find_if (itBeg, itEnd, match); } } if (toDelete.empty()) printf ("no file will be deindexed\n"); else { for (vector<string>::iterator iter = toDelete.begin(); iter != toDelete.end(); ++iter) { printf ("%s will be deindex\n", iter->c_str()); } IndexWriter* writer = manager->indexWriter(); writer->deleteEntries(toDelete); writer->commit(); writer->optimize(); } IndexPluginLoader::deleteIndexManager(manager); return 0; }