本文整理汇总了C#中Lucene.Net.Store.Directory.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Directory.Dispose方法的具体用法?C# Directory.Dispose怎么用?C# Directory.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Store.Directory
的用法示例。
在下文中一共展示了Directory.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckDirectoryFilter
// LUCENE-1468
private void CheckDirectoryFilter(Directory dir)
{
string name = "file";
try
{
dir.CreateOutput(name, NewIOContext(Random())).Dispose();
Assert.IsTrue(SlowFileExists(dir, name));
Assert.IsTrue(Arrays.AsList(dir.ListAll()).Contains(name));
}
finally
{
dir.Dispose();
}
}
示例2: MedesSearch
/// <summary>
/// Perform search
/// </summary>
/// <param name="query"></param>
/// <param name="startIndex"></param>
/// <param name="blockSize"></param>
/// <param name="indexDirEs"></param>
/// <param name="indexDirEn"></param>
/// <param name="sortBy"></param>
/// <returns></returns>
public List<IssueDocument> MedesSearch(Query query, int startIndex, int blockSize, Directory indexDirEs, Directory indexDirEn, Directory indexDirHe, string sortBy)
{
#if DEBUG
T.TraceMessage(string.Format("Begin search , query: '{0}'", query.ToString()));
#endif
List<IssueDocument> result = new List<IssueDocument>();
try
{
// build a multi searcher across the 2 indexes
MultiSearcher mSearcher = CombineSearchers(indexDirEs, indexDirEn, indexDirHe);
TopDocs tDocs = null;
int iterateLast = startIndex + blockSize;
string customScoreField = "article_id";
FieldScoreQuery dateBooster = new FieldScoreQuery(customScoreField, FieldScoreQuery.Type.FLOAT);
CustomScoreQuery customQuery = new CustomScoreQuery(query, dateBooster);
tDocs = mSearcher.Search(customQuery, 1000);
//ScoreDoc[] hits = tpDcs.scoreDocs;
if (startIndex + blockSize > tDocs.TotalHits) iterateLast = tDocs.TotalHits;
for (int i = startIndex; i < iterateLast; i++)
{
// Document hitDoc = mSearcher.Doc(hits[i].doc);
Document hitDoc = mSearcher.Doc(i);
result.Add(new IssueDocument() { Id = Int32.Parse(hitDoc.Get("issue_id").ToString())});
}
// close the searcher and indexes
mSearcher.Dispose();
indexDirEs.Dispose();
indexDirEn.Dispose();
indexDirHe.Dispose();
}
catch (Exception ex)
{
T.TraceError("Error MedesSearch, query '{0}'", query.ToString());
T.TraceError(ex);
throw ex;
}
return result;
}
示例3: RAMDirectory
private RAMDirectory(Directory dir, bool closeDir, IOContext context)
: this()
{
foreach (string file in dir.ListAll())
{
dir.Copy(this, file, file, context);
}
if (closeDir)
{
dir.Dispose();
}
}
示例4: GRandom
public void GRandom()
{
int numDocs = TestUtil.NextInt(Random(), (10 * RANDOM_MULTIPLIER),
(100 * RANDOM_MULTIPLIER));
Directory dir = null;
RandomIndexWriter writer = null;
IndexReader ir = null;
try
{
dir = NewDirectory();
writer = new RandomIndexWriter(Random(), dir, new MockAnalyzer(Random(),
MockTokenizer.WHITESPACE, false), Similarity, TimeZone);
int maxLength = TestUtil.NextInt(Random(), 5, 50);
List<string> originals = new List<string>(numDocs);
List<string[]> breaks = new List<string[]>(numDocs);
for (int i = 0; i < numDocs; i++)
{
string orig = "";
if (Random().nextBoolean())
{
while (!GoodTestString(orig))
{
orig = TestUtil.RandomSimpleString(Random(), maxLength);
}
}
else
{
while (!GoodTestString(orig))
{
orig = TestUtil.RandomUnicodeString(Random(), maxLength);
}
}
originals.Add(orig);
int totalLength = orig.CodePointCount(0, orig.Length);
int breakAt = orig.OffsetByCodePoints(0,
TestUtil.NextInt(Random(), 1, totalLength - 1));
string[] broken = new string[2];
broken[0] = orig.Substring(0, breakAt - 0);
broken[1] = orig.Substring(breakAt);
breaks.Add(broken);
Document doc = new Document();
doc.Add(NewTextField("random_break", broken[0] + " " + broken[1],
Field.Store.NO));
doc.Add(NewTextField("random_combine", orig, Field.Store.NO));
writer.AddDocument(doc);
}
writer.Commit();
writer.Dispose();
ir = DirectoryReader.Open(dir);
WordBreakSpellChecker wbsp = new WordBreakSpellChecker();
wbsp.MaxChanges = (1);
wbsp.MinBreakWordLength = (1);
wbsp.MinSuggestionFrequency = (1);
wbsp.MaxCombineWordLength = (maxLength);
for (int i = 0; i < originals.size(); i++)
{
string orig = originals[i];
string left = breaks[i][0];
string right = breaks[i][1];
{
Term term = new Term("random_break", orig);
SuggestWord[][] sw = wbsp.SuggestWordBreaks(term, originals.size(),
ir, SuggestMode.SUGGEST_ALWAYS,
WordBreakSpellChecker.BreakSuggestionSortMethod.NUM_CHANGES_THEN_MAX_FREQUENCY);
bool failed = true;
foreach (SuggestWord[] sw1 in sw)
{
assertTrue(sw1.Length == 2);
if (sw1[0].String.equals(left) && sw1[1].String.equals(right))
{
failed = false;
}
}
assertFalse("Failed getting break suggestions\n >Original: "
+ orig + "\n >Left: " + left + "\n >Right: " + right, failed);
}
{
Term[] terms = {new Term("random_combine", left),
new Term("random_combine", right)};
CombineSuggestion[] cs = wbsp.SuggestWordCombinations(terms,
originals.size(), ir, SuggestMode.SUGGEST_ALWAYS);
bool failed = true;
foreach (CombineSuggestion cs1 in cs)
{
assertTrue(cs1.OriginalTermIndexes.Length == 2);
if (cs1.Suggestion.String.equals(left + right))
{
failed = false;
}
}
assertFalse("Failed getting combine suggestions\n >Original: "
+ orig + "\n >Left: " + left + "\n >Right: " + right, failed);
}
}
}
catch (Exception e)
{
//.........这里部分代码省略.........