本文整理汇总了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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}