本文整理汇总了C#中Lucene.Net.Store.Directory类的典型用法代码示例。如果您正苦于以下问题:C# Directory类的具体用法?C# Directory怎么用?C# Directory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Directory类属于Lucene.Net.Store命名空间,在下文中一共展示了Directory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public override void SetUp()
{
base.SetUp();
store = NewDirectory();
IndexWriter writer = new IndexWriter(store, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random(), MockTokenizer.WHITESPACE, false)));
Document doc;
doc = new Document();
doc.Add(NewTextField("aaa", "foo", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(NewTextField("aaa", "foo", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(NewTextField("contents", "Tom", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(NewTextField("contents", "Jerry", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(NewTextField("zzz", "bar", Field.Store.YES));
writer.AddDocument(doc);
writer.ForceMerge(1);
writer.Dispose();
}
示例2: LocalPackageIndex
/// <summary>
/// ctor for unit tests
/// </summary>
internal LocalPackageIndex(LuceneDirectory directory, IPackageSearchEngine engine, IReflectorFactory reflectorFactory, ILog logger)
{
_directory = directory;
_engine = engine;
_reflectorFactory = reflectorFactory;
Logger = logger;
}
示例3: Main
public static void Main(string[] args)
{
if (args.Length < 3)
{
Console.Error.WriteLine("Usage: IndexMergeTool <mergedIndex> <index1> <index2> [index3] ...");
Environment.Exit(1);
}
FSDirectory mergedIndex = FSDirectory.Open(new System.IO.DirectoryInfo(args[0]));
#pragma warning disable 612, 618
using (IndexWriter writer = new IndexWriter(mergedIndex, new IndexWriterConfig(LuceneVersion.LUCENE_CURRENT, null)
.SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE)))
#pragma warning restore 612, 618
{
Directory[] indexes = new Directory[args.Length - 1];
for (int i = 1; i < args.Length; i++)
{
indexes[i - 1] = FSDirectory.Open(new System.IO.DirectoryInfo(args[i]));
}
Console.WriteLine("Merging...");
writer.AddIndexes(indexes);
Console.WriteLine("Full merge...");
writer.ForceMerge(1);
}
Console.WriteLine("Done.");
}
示例4: TestSetup
public void TestSetup()
{
UmbracoExamineSearcher.DisableInitializationCheck = true;
BaseUmbracoIndexer.DisableInitializationCheck = true;
//we'll copy over the pdf files first
var svc = new TestDataService();
var path = svc.MapPath("/App_Data/Converting_file_to_PDF.pdf");
var f = new FileInfo(path);
var dir = f.Directory;
//ensure the folder is there
System.IO.Directory.CreateDirectory(dir.FullName);
var pdfs = new[] { TestFiles.Converting_file_to_PDF, TestFiles.PDFStandards, TestFiles.SurviorFlipCup, TestFiles.windows_vista };
var names = new[] { "Converting_file_to_PDF.pdf", "PDFStandards.pdf", "SurviorFlipCup.pdf", "windows_vista.pdf" };
for (int index = 0; index < pdfs.Length; index++)
{
var p = pdfs[index];
using (var writer = File.Create(Path.Combine(dir.FullName, names[index])))
{
writer.Write(p, 0, p.Length);
}
}
_luceneDir = new RAMDirectory();
_indexer = IndexInitializer.GetPdfIndexer(_luceneDir);
_indexer.RebuildIndex();
_searcher = IndexInitializer.GetUmbracoSearcher(_luceneDir);
}
示例5: SuggestionQueryIndexExtension
public SuggestionQueryIndexExtension(
WorkContext workContext,
string key,
StringDistance distanceType,
bool isRunInMemory,
string field,
float accuracy)
{
this.workContext = workContext;
this.key = key;
this.field = field;
if (isRunInMemory)
{
directory = new RAMDirectory();
}
else
{
directory = FSDirectory.Open(new DirectoryInfo(key));
}
this.spellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(directory, null);
this.spellChecker.SetAccuracy(accuracy);
this.spellChecker.setStringDistance(distanceType);
}
示例6: SetUp
public override void SetUp()
{
base.SetUp();
dir = NewDirectory();
var iw = new RandomIndexWriter(Random(), dir, Similarity, TimeZone);
var doc = new Document
{
NewStringField("id", "1", Field.Store.YES),
NewTextField("body", "some contents and more contents", Field.Store.NO),
new NumericDocValuesField("popularity", 5)
};
iw.AddDocument(doc);
doc = new Document
{
NewStringField("id", "2", Field.Store.YES),
NewTextField("body", "another document with different contents", Field.Store
.NO),
new NumericDocValuesField("popularity", 20)
};
iw.AddDocument(doc);
doc = new Document
{
NewStringField("id", "3", Field.Store.YES),
NewTextField("body", "crappy contents", Field.Store.NO),
new NumericDocValuesField("popularity", 2)
};
iw.AddDocument(doc);
reader = iw.Reader;
searcher = new IndexSearcher(reader);
iw.Dispose();
}
示例7: SetUp
public override void SetUp()
{
base.SetUp();
dir = NewDirectory();
var iw = new RandomIndexWriter(Random(), dir, Similarity, TimeZone);
int numDocs = TestUtil.NextInt(Random(), 2049, 4000);
for (int i = 0; i < numDocs; i++)
{
var document = new Document
{
NewTextField("english", English.IntToEnglish(i), Field.Store.NO),
NewTextField("oddeven", (i%2 == 0) ? "even" : "odd", Field.Store.NO
),
NewStringField("byte", string.Empty + (unchecked((byte) Random().Next
())), Field.Store.NO),
NewStringField("short", string.Empty + ((short) Random().Next()), Field.Store
.NO),
new IntField("int", Random().Next(), Field.Store.NO),
new LongField("long", Random().NextLong(), Field.Store.NO),
new FloatField("float", Random().NextFloat(), Field.Store.NO),
new DoubleField("double", Random().NextDouble(), Field.Store.NO),
new NumericDocValuesField("intdocvalues", Random().Next()),
new FloatDocValuesField("floatdocvalues", Random().NextFloat())
};
iw.AddDocument(document);
}
reader = iw.Reader;
iw.Dispose();
searcher = NewSearcher(reader);
}
示例8: SetUp
public override void SetUp()
{
base.SetUp();
_dir = NewDirectory();
_indexWriter = new RandomIndexWriter(Random(), _dir, new MockAnalyzer(Random()), Similarity, TimeZone);
FieldType ft = new FieldType(TextField.TYPE_STORED);
ft.StoreTermVectors = true;
ft.StoreTermVectorOffsets = true;
ft.StoreTermVectorPositions = true;
Analyzer analyzer = new MockAnalyzer(Random());
Document doc;
for (int i = 0; i < 100; i++)
{
doc = new Document();
doc.Add(new Field(_idFieldName, Random().toString(), ft));
doc.Add(new Field(_textFieldName, new StringBuilder(Random().toString()).append(Random().toString()).append(
Random().toString()).toString(), ft));
doc.Add(new Field(_classFieldName, Random().toString(), ft));
_indexWriter.AddDocument(doc, analyzer);
}
_indexWriter.Commit();
_originalIndex = SlowCompositeReaderWrapper.Wrap(_indexWriter.Reader);
}
示例9: Initialize
public void Initialize()
{
_cwsDir = new RAMDirectory();
_pdfDir = new RAMDirectory();
_simpleDir = new RAMDirectory();
_conventionDir = new RAMDirectory();
//get all of the indexers and rebuild them all first
var indexers = new IIndexer[]
{
IndexInitializer.GetUmbracoIndexer(_cwsDir),
IndexInitializer.GetSimpleIndexer(_simpleDir),
IndexInitializer.GetUmbracoIndexer(_conventionDir)
};
foreach (var i in indexers)
{
try
{
i.RebuildIndex();
}
finally
{
var d = i as IDisposable;
if (d != null) d.Dispose();
}
}
//now get the multi index searcher for all indexes
_searcher = IndexInitializer.GetMultiSearcher(_pdfDir, _simpleDir, _conventionDir, _cwsDir);
}
示例10: SearchAutoComplete
public SearchAutoComplete(Directory autoCompleteDir, int maxResults = 8)
{
this.m_directory = autoCompleteDir;
MaxResults = maxResults;
ReplaceSearcher();
}
示例11: NAppIndexUpdater
public NAppIndexUpdater(Configuration.ConfigManager config, Database currentDb)
{
indexFullPath = config.GetSetting(SettingKeys.Index_Directory, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Index"));
indexFullPath = System.IO.Path.GetFullPath(indexFullPath);
directory = FSDirectory.Open(new System.IO.DirectoryInfo(indexFullPath));
this.currentDb = currentDb;
}
示例12: SetUp
public override void SetUp()
{
base.SetUp();
dir = NewDirectory();
IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer
(Random()));
iwc.SetMergePolicy(NewLogMergePolicy());
var iw = new RandomIndexWriter(Random(), dir, iwc);
var doc = new Document
{
NewStringField("id", "1", Field.Store.YES),
NewTextField("body", "some contents and more contents", Field.Store.NO),
new NumericDocValuesField("popularity", 5)
};
iw.AddDocument(doc);
doc = new Document
{
NewStringField("id", "2", Field.Store.YES),
NewTextField("body", "another document with different contents", Field.Store
.NO),
new NumericDocValuesField("popularity", 20)
};
iw.AddDocument(doc);
doc = new Document
{
NewStringField("id", "3", Field.Store.YES),
NewTextField("body", "crappy contents", Field.Store.NO),
new NumericDocValuesField("popularity", 2)
};
iw.AddDocument(doc);
iw.ForceMerge(1);
reader = iw.Reader;
iw.Dispose();
}
示例13: MultiIndexLockFactory
public MultiIndexLockFactory(Lucene.Net.Store.Directory master, Lucene.Net.Store.Directory child)
{
if (master == null) throw new ArgumentNullException("master");
if (child == null) throw new ArgumentNullException("child");
_master = master;
_child = child;
}
示例14: CloseStaleReaders
public int CloseStaleReaders(Directory dir, TimeSpan ts)
{
lock (_locker)
{
var now = DateTime.Now;
var readersForDir = _oldReaders.Where(x => x.Item1.Directory().GetLockID() == dir.GetLockID()).ToList();
var newest = readersForDir.OrderByDescending(x => x.Item2).FirstOrDefault();
readersForDir.Remove(newest);
var stale = readersForDir.Where(x => now - x.Item2 >= ts).ToArray();
foreach (var reader in stale)
{
//close reader and remove from list
try
{
reader.Item1.Close();
}
catch (AlreadyClosedException)
{
//if this happens, more than one instance has decreased referenced, this could occur if this
//somehow gets called in conjuction with the shutdown code or manually, etc...
}
_oldReaders.Remove(reader);
}
return stale.Length;
}
}
示例15: CheckSplitting
private void CheckSplitting(Directory dir, Term splitTerm, int leftCount, int rightCount)
{
using (Directory dir1 = NewDirectory())
{
using (Directory dir2 = NewDirectory())
{
PKIndexSplitter splitter = new PKIndexSplitter(dir, dir1, dir2, splitTerm,
NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())),
NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
splitter.Split();
using (IndexReader ir1 = DirectoryReader.Open(dir1))
{
using (IndexReader ir2 = DirectoryReader.Open(dir2))
{
assertEquals(leftCount, ir1.NumDocs);
assertEquals(rightCount, ir2.NumDocs);
CheckContents(ir1, "1");
CheckContents(ir2, "2");
}
}
}
}
}