public static IWorker CreateWorker(Configuration cfg, SearchFactoryImpl searchFactory) { IWorker worker = new TransactionalWorker(); worker.Initialize((IDictionary)cfg.Properties, searchFactory); return(worker); }
public void PurgeAll() { using (ISession s = OpenSession()) { SearchFactoryImpl searchFactory = SearchFactoryImpl.GetSearchFactory(cfg); System.Type targetType = typeof(Document); IDirectoryProvider provider = searchFactory.GetDirectoryProviders(targetType)[0]; Workspace workspace = new Workspace(searchFactory); using (ITransaction tx = s.BeginTransaction()) { Document doc = new Document("Hibernate in Action", "Object and Relational", "blah blah blah"); searchFactory.PerformWork(doc, 1, s, WorkType.Add); doc = new Document("Object and Relational", "Hibernate in Action", "blah blah blah"); searchFactory.PerformWork(doc, 2, s, WorkType.Add); tx.Commit(); } Assert.AreEqual(2, workspace.GetIndexReader(provider, targetType).NumDocs, "Documents created"); using (ITransaction tx = s.BeginTransaction()) { LuceneWorker luceneWorker = new LuceneWorker(workspace); luceneWorker.PerformWork(new PurgeAllLuceneWork(targetType), provider); } Assert.AreEqual(0, workspace.GetIndexReader(provider, targetType).NumDocs, "Document purgation"); } }
public void UnsetBatchValueTakesTransaction() { IFullTextSession fullTextSession = Search.CreateFullTextSession(OpenSession()); SearchFactoryImpl searchFactory = (SearchFactoryImpl)fullTextSession.SearchFactory; LuceneIndexingParameters indexingParameters = searchFactory.GetIndexingParameters(searchFactory.GetDirectoryProviders(typeof(DocumentTop))[0]); Assert.AreEqual(10, (int)indexingParameters.BatchIndexParameters.MergeFactor); Assert.AreEqual(1000, (int)indexingParameters.BatchIndexParameters.MaxBufferedDocs); Assert.AreEqual(99, (int)indexingParameters.BatchIndexParameters.TermIndexInterval); fullTextSession.Close(); }
public void BatchParametersDefault() { IFullTextSession fullTextSession = Search.CreateFullTextSession(OpenSession()); SearchFactoryImpl searchFactory = (SearchFactoryImpl)fullTextSession.SearchFactory; LuceneIndexingParameters indexingParameters = searchFactory.GetIndexingParameters(searchFactory.GetDirectoryProviders(typeof(Query.Author))[0]); Assert.AreEqual(1, (int)indexingParameters.BatchIndexParameters.RamBufferSizeMb); Assert.AreEqual(9, (int)indexingParameters.BatchIndexParameters.MaxMergeDocs); Assert.AreEqual(1000, (int)indexingParameters.BatchIndexParameters.MaxBufferedDocs); Assert.AreEqual(10, (int)indexingParameters.BatchIndexParameters.MergeFactor); fullTextSession.Close(); }
public static IEnumerable <object> GetIds(SearchFactoryImpl sf, IndexSearcher searcher, Type type, Query query) { var doccount = searcher.GetIndexReader().MaxDoc(); if (doccount == 0) { return(new List <object>()); } var docs = searcher.Search(query, doccount); return(docs.ScoreDocs.Select(t => DocumentBuilder.GetDocumentId(sf, type, searcher.Doc(t.doc)))); }
public void TransactionParameters() { IFullTextSession fullTextSession = Search.CreateFullTextSession(OpenSession()); SearchFactoryImpl searchFactory = (SearchFactoryImpl)fullTextSession.SearchFactory; LuceneIndexingParameters indexingParameters = searchFactory.GetIndexingParameters(searchFactory.GetDirectoryProviders(typeof(Query.Book))[0]); Assert.AreEqual(4, (int)indexingParameters.TransactionIndexParameters.RamBufferSizeMb); Assert.AreEqual(15, (int)indexingParameters.TransactionIndexParameters.MaxMergeDocs); Assert.AreEqual(17, (int)indexingParameters.TransactionIndexParameters.MaxBufferedDocs); Assert.AreEqual(16, (int)indexingParameters.TransactionIndexParameters.MergeFactor); Assert.AreEqual(101, (int)indexingParameters.TransactionIndexParameters.TermIndexInterval); fullTextSession.Close(); }
public void Initialize(Configuration cfg) { searchFactory = SearchFactoryImpl.GetSearchFactory(cfg); string indexingStrategy = cfg.GetProperty(Environment.IndexingStrategy) ?? "event"; if ("event".Equals(indexingStrategy)) { used = searchFactory.DocumentBuilders.Count != 0; } else if ("manual".Equals(indexingStrategy)) { used = false; } else { throw new SearchException(Environment.IndexBase + " unknown: " + indexingStrategy); } }
public static IEnumerable <object> GetIds(SearchFactoryImpl sf, Type type, Query query) { Iesi.Collections.Generic.ISet <Type> types; var searcher = FullTextSearchHelper.BuildSearcher(sf, out types, type); if (searcher == null) { throw new SearchException("Could not find a searcher for class: " + type.FullName); } try { var q = FullTextSearchHelper.FilterQueryByClasses(types, query); return(GetIds(sf, searcher, type, q)); } finally { searcher.Close(); } }
public void Optimize() { var searchFactory = SearchFactoryImpl.GetSearchFactory(thisRepo.context.CurrentConfiguration); searchFactory.Optimize(typeof(T)); }
public void Initialize(IDictionary props, SearchFactoryImpl searchFactory) { queueingProcessor = new BatchedQueueingProcessor(searchFactory, props); }