当前位置: 首页>>代码示例>>C#>>正文


C# IndexReader.Directory方法代码示例

本文整理汇总了C#中Lucene.Net.Index.IndexReader.Directory方法的典型用法代码示例。如果您正苦于以下问题:C# IndexReader.Directory方法的具体用法?C# IndexReader.Directory怎么用?C# IndexReader.Directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Index.IndexReader的用法示例。


在下文中一共展示了IndexReader.Directory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SuggestionQueryIndexExtension

		public SuggestionQueryIndexExtension(
			string key,
			IndexReader reader,
			StringDistance distance, 
			string field, 
			float accuracy)
		{
			this.key = key;
			this.field = field;
			
			if(reader.Directory() is RAMDirectory)
			{
				directory = new RAMDirectory();
			}
			else
			{
				directory = FSDirectory.Open(new DirectoryInfo(key));
			}

			this.spellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(directory, distance);
			this.spellChecker.SetAccuracy(accuracy);
		}
开发者ID:remcoros,项目名称:ravendb,代码行数:22,代码来源:SuggestionQueryIndexExtension.cs

示例2: CloseInternalReader

        private void CloseInternalReader(bool trace, IndexReader subReader, bool finalClose)
        {
            ReaderData readerData;
            // TODO: can we avoid the lock?
            lock (semaphoreIndexReaderLock)
            {
                readerData = searchIndexReaderSemaphores[subReader];
            }

            if (readerData == null)
            {
                log.Error("Trying to close a Lucene IndexReader not present: " + subReader.Directory());
                // TODO: Should we try to close?
                return;
            }

            // Acquire the locks in the same order as everywhere else
            object directoryProviderLock = perDirectoryProviderManipulationLocks[readerData.Provider];
            bool closeReader = false;
            lock (directoryProviderLock)
            {
                IndexReader reader;
                bool isActive = activeSearchIndexReaders.TryGetValue(readerData.Provider, out reader)
                    && reader == subReader;
                if (trace) log.Info("IndexReader not active: " + subReader);
                lock (semaphoreIndexReaderLock)
                {
                    readerData = searchIndexReaderSemaphores[subReader];
                    if (readerData == null)
                    {
                        log.Error("Trying to close a Lucene IndexReader not present: " + subReader.Directory());
                        // TODO: Should we try to close?
                        return;
                    }

                    //final close, the semaphore should be at 0 already
                    if (!finalClose)
                    {
                        readerData.Semaphore--;
                        if (trace)
                            log.Info("Semaphore decreased to: " + readerData.Semaphore + " for " + subReader);
                    }

                    if (readerData.Semaphore < 0)
                        log.Error("Semaphore negative: " + subReader.Directory());

                    if (!isActive && readerData.Semaphore == 0)
                    {
                        searchIndexReaderSemaphores.Remove(subReader);
                        closeReader = true;
                    }
                    else
                        closeReader = false;
                }
            }

            if (closeReader)
            {
                if (trace) log.Info("Closing IndexReader: " + subReader);
                try
                {
                    subReader.Close();
                }
                catch (IOException e)
                {
                    log.Warn("Unable to close Lucene IndexReader", e);
                }
            }
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:69,代码来源:SharedReaderProvider.cs

示例3: FilterIndexReader

 /// <summary> <p>Construct a FilterIndexReader based on the specified base reader.
 /// Directory locking for delete, undeleteAll, and setNorm operations is
 /// left to the base reader.</p>
 /// <p>Note that base reader is closed if this FilterIndexReader is closed.</p>
 /// </summary>
 /// <param name="in">specified base reader.
 /// </param>
 public FilterIndexReader(IndexReader in_Renamed)
     : base(in_Renamed.Directory())
 {
     this.in_Renamed = in_Renamed;
 }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:12,代码来源:FilterIndexReader.cs

示例4: SuggestSimilar

        /// <summary>
        /// Gets the similar words.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="word">The word.</param>
        /// <returns></returns>
        private static string[] SuggestSimilar(IndexReader reader, string fieldName, string word)
        {
            var spell = new SpellChecker.Net.Search.Spell.SpellChecker(reader.Directory());
            spell.IndexDictionary(new LuceneDictionary(reader, fieldName));
            var similarWords = spell.SuggestSimilar(word, 2);

            // now make sure to close the spell checker
            spell.Close();

            return similarWords;
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:18,代码来源:LuceneSearchResults.cs

示例5: GetDocIdSet

        public override DocIdSet GetDocIdSet(IndexReader reader)
        {
            DocIdSet docs = null;

            // TODO: override by SinSay
            var cache = IdSetCache.GetCache(reader.Directory().ToString(), this.fieldName);
            if (cache != null)
            {
                return cache.Cache;
            }

            if (processingMode == PM_FAST_INVALIDATION)
            {
                docs = FastBits(reader);
            }
            else
            {
                docs = CorrectBits(reader);
            }

            return docs;
        }
开发者ID:sinsay,项目名称:SSE,代码行数:22,代码来源:DuplicateFilter.cs


注:本文中的Lucene.Net.Index.IndexReader.Directory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。