本文整理汇总了C#中Schema.IsDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.IsDefault方法的具体用法?C# Schema.IsDefault怎么用?C# Schema.IsDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema.IsDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LuceneIndex
/// <summary>
/// Initializes a new instance of the <see cref="LuceneIndex" /> class.
/// </summary>
/// <param name="indexPath">The path to the directory that will contain the Lucene index files.</param>
/// <param name="schema">The schema.</param>
/// <exception cref="System.ArgumentNullException"></exception>
public LuceneIndex(string indexPath, Schema schema)
{
if (String.IsNullOrWhiteSpace(indexPath))
throw new ArgumentNullException(nameof(indexPath));
if (schema == null)
throw new ArgumentNullException(nameof(schema));
IndexPath = indexPath;
Schema = schema;
if (System.IO.Directory.Exists(IndexPath))
{
if (Schema.IsDefault())
throw new InvalidOperationException($"There is an existing index on '{IndexPath}'.");
}
else
{
System.IO.Directory.CreateDirectory(IndexPath);
}
_indexDirectory = new MMapDirectory(Paths.get(IndexPath));
var taxonomyIndexPath = System.IO.Path.Combine(IndexPath, "taxonomy");
if (!System.IO.Directory.Exists(taxonomyIndexPath))
System.IO.Directory.CreateDirectory(taxonomyIndexPath);
_taxonomyDirectory = new MMapDirectory(Paths.get(taxonomyIndexPath));
_compositeAnalyzer = new CompositeAnalyzer(Schema);
_ramBufferSizeMB = Double.Parse(ConfigurationManager.AppSettings["IndexWriter.RAMBufferSizeMB"] ?? "128");
var config = new IndexWriterConfig(_compositeAnalyzer)
.SetOpenMode(IndexWriterConfigOpenMode.CREATE_OR_APPEND)
.SetRAMBufferSizeMB(_ramBufferSizeMB)
.SetCommitOnClose(true);
_indexWriter = new IndexWriter(_indexDirectory, config);
_taxonomyWriter = new DirectoryTaxonomyWriter(_taxonomyDirectory, IndexWriterConfigOpenMode.CREATE_OR_APPEND);
_searcherTaxonomyManager = new SearcherTaxonomyManager(_indexWriter, true, null, _taxonomyWriter);
_facetBuilder = new LuceneFacetBuilder(_taxonomyWriter);
_refreshIntervalSeconds = Double.Parse(ConfigurationManager.AppSettings["IndexSearcher.RefreshIntervalSeconds"] ?? "0.5");
_commitIntervalSeconds = Double.Parse(ConfigurationManager.AppSettings["IndexWriter.CommitIntervalSeconds"] ?? "60");
_writeAllowedFlag = new ManualResetEventSlim(true);
_refreshTimer = new Timer(o => Refresh(), null, TimeSpan.FromSeconds(_refreshIntervalSeconds), TimeSpan.FromSeconds(_refreshIntervalSeconds));
_commitTimer = new Timer(o => Commit(), null, TimeSpan.FromSeconds(_commitIntervalSeconds), TimeSpan.FromSeconds(_commitIntervalSeconds));
}