/** * Calls the method index(Collection[]) of the * class Indexer in order to build the data * structures for a set of collections. This * particular method of the Indexer uses a * set of builders for a subset of the collection * and builds separate data structures, which are * later merged. */ @Override public void index() { if (Index.existsIndex(path, prefix)) { logger.error("Cannot index while an index exists at "+path + ","+ prefix); return; } loadIndexer(path, prefix).index(new Collection[] {collectionTREC}); try{ collectionTREC.close(); } catch (Exception e) { logger.warn("problem closing collection", e); } }
public static Index makeIndexFields(String[] docnos, String[] documents, Indexer indexer, String path, String prefix) throws Exception { assertFalse("Index at "+ path + "," + prefix + " already exists!", IndexOnDisk.existsIndex(path, prefix)); assertEquals(docnos.length, documents.length); Document[] sourceDocs = new Document[docnos.length]; for(int i=0;i<docnos.length;i++) { Map<String,String> docProperties = new HashMap<String,String>(); docProperties.put("filename", docnos[i]); docProperties.put("docno", docnos[i]); sourceDocs[i] = new TaggedDocument(new ByteArrayInputStream(documents[i].getBytes()), docProperties, new EnglishTokeniser()); } Collection col = new CollectionDocumentList(sourceDocs, "filename"); indexer.index(new Collection[]{col}); Index index = Index.createIndex(path, prefix); assertNotNull(index); assertEquals(sourceDocs.length, index.getCollectionStatistics().getNumberOfDocuments()); return index; }
public static Index makeIndex(String[] docnos, String[] documents, Indexer indexer, String path, String prefix) throws Exception { assertFalse("Index at "+ path + "," + prefix + " already exists!", IndexOnDisk.existsIndex(path, prefix)); assertEquals(docnos.length, documents.length); Document[] sourceDocs = new Document[docnos.length]; for(int i=0;i<docnos.length;i++) { Map<String,String> docProperties = new HashMap<String,String>(); docProperties.put("filename", docnos[i]); docProperties.put("docno", docnos[i]); sourceDocs[i] = makeDocumentFromText(documents[i], docProperties); } Collection col = makeCollection(docnos, documents); indexer.index(new Collection[]{col}); Index index = Index.createIndex(path, prefix); assertNotNull(index); assertEquals(sourceDocs.length, index.getCollectionStatistics().getNumberOfDocuments()); return index; }
public static Index makeIndex(String[] docnos, String[] documents, Indexer indexer) throws Exception { assertEquals(docnos.length, documents.length); Document[] sourceDocs = new Document[docnos.length]; for(int i=0;i<docnos.length;i++) { Map<String,String> docProperties = new HashMap<String,String>(); docProperties.put("filename", docnos[i]); sourceDocs[i] = new FileDocument(new ByteArrayInputStream(documents[i].getBytes()), docProperties, new EnglishTokeniser()); } Collection col = new CollectionDocumentList(sourceDocs, "filename"); indexer.index(new Collection[]{col}); Index index = Index.createIndex(); assertEquals(sourceDocs.length, index.getCollectionStatistics().getNumberOfDocuments()); return index; }