/// <summary> /// get the specified analyzer /// </summary> /// <param name="indexerAnalyzer"></param> /// <param name="isSub"></param> /// <returns></returns> protected Analyzer GetAnalyzer(IndexerAnalyzer indexerAnalyzer, bool isSub) { Analyzer analyzer = null; switch (indexerAnalyzer) { case IndexerAnalyzer.KeywordAnalyzer: analyzer = new KeywordAnalyzer(); break; case IndexerAnalyzer.PerFieldAnalyzerWrapper: if (!isSub) { analyzer = new PerFieldAnalyzerWrapper(new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30)); } else { analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30); } break; case IndexerAnalyzer.SimpleAnalyzer: analyzer = new SimpleAnalyzer(); break; case IndexerAnalyzer.StopAnalyzer: analyzer = new StopAnalyzer(Lucene.Net.Util.Version.LUCENE_30); break; case IndexerAnalyzer.WhitespaceAnalyzer: analyzer = new WhitespaceAnalyzer(); break; case IndexerAnalyzer.StandardAnalyzer: default: analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30); break; } if (isSub) { } return(analyzer); }
/// <summary> /// constructor /// </summary> /// <param name="indexFullPath"></param> /// <param name="indexMode"></param> /// <param name="indexerDocumentUniqueIdentifier"></param> /// <param name="analyzer"></param> /// <param name="dataItemHandler"></param> /// <param name="perFieldAnalyzers"></param> public ISIndexer(string indexFullPath, IndexerStorageMode indexMode, string indexerDocumentUniqueIdentifier, IndexerAnalyzer analyzer, Dictionary <string, IndexerAnalyzer> perFieldAnalyzers = null) { this.indexMode = indexMode; if (analyzer != IndexerAnalyzer.PerFieldAnalyzerWrapper) { this.analyzer = GetAnalyzer(analyzer, false); } else { this.analyzer = GetAnalyzer(analyzer, false); if (perFieldAnalyzers != null) { foreach (KeyValuePair <string, IndexerAnalyzer> kvp in perFieldAnalyzers) { (this.analyzer as PerFieldAnalyzerWrapper).AddAnalyzer(kvp.Key, GetAnalyzer(kvp.Value, true)); } } } if (!String.IsNullOrEmpty(indexFullPath)) { this.luceneIndexFullPath = Path.GetFullPath(indexFullPath); } if (luceneIndexDirectory == null) { throw new System.IO.IOException("unable to setup indexing folder"); } if (!String.IsNullOrEmpty(indexerDocumentUniqueIdentifier)) { this.indexerDocumentUniqueIdentifierFieldName = indexerDocumentUniqueIdentifier; } this.indexSearcher = new IndexSearcher(luceneIndexDirectory, true); this.OnIndexSearcherUpdateRequested += IndexSearcherUpdater; this.MaxSearchHits = 1000; // DEFAULT }
/// <summary> /// constructor /// </summary> /// <param name="indexFullPath"></param> /// <param name="indexMode"></param> /// <param name="analyzer"></param> /// <param name="dataItemHandler"></param> /// <param name="perFieldAnalyzers"></param> public ISIndexer(string indexFullPath, IndexerStorageMode indexMode, IndexerAnalyzer analyzer, Dictionary <string, IndexerAnalyzer> perFieldAnalyzers = null) : this(indexFullPath, indexMode, null, analyzer, perFieldAnalyzers) { }