• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Store.Directory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Directory类属于Lucene.Net.Store命名空间,在下文中一共展示了Directory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:31,代码来源:TestLuceneDictionary.cs


示例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;
 }
开发者ID:digideskio,项目名称:NuGet.PackageIndex,代码行数:10,代码来源:LocalPackageIndex.cs


示例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.");
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:29,代码来源:IndexMergeTool.cs


示例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);
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:27,代码来源:PdfIndexerTests.cs


示例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);
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:25,代码来源:SuggestionQueryIndexExtension.cs


示例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();
		}
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:31,代码来源:TestExpressionRescorer.cs


示例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);
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:30,代码来源:TestExpressionSorts.cs


示例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);
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:28,代码来源:DataSplitterTest.cs


示例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);
        }
开发者ID:Xamarui,项目名称:Examine,代码行数:30,代码来源:MultiIndexSearch.cs


示例10: SearchAutoComplete

        public SearchAutoComplete(Directory autoCompleteDir, int maxResults = 8)
        {
            this.m_directory = autoCompleteDir;
            MaxResults = maxResults;

            ReplaceSearcher();
        }
开发者ID:jneufeld,项目名称:cs319,代码行数:7,代码来源:SearchAutocomplete.cs


示例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;
 }
开发者ID:simonkang,项目名称:NAppProfiler,代码行数:7,代码来源:NAppIndexUpdater.cs


示例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();
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:34,代码来源:TestExpressionValueSource.cs


示例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;
 }
开发者ID:jclementson,项目名称:Examine,代码行数:7,代码来源:MultiIndexLockFactory.cs


示例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;
            }
            
        }
开发者ID:Xamarui,项目名称:Examine,代码行数:29,代码来源:OpenReaderTracker.cs


示例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");

                        }
                    }
                }
            }
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:27,代码来源:TestPKIndexSplitter.cs


示例16: CreateRandomIndexes

 private void CreateRandomIndexes(int maxSegments)
 {
     dir = NewDirectory();
     numDocs = AtLeast(150);
     int numTerms = TestUtil.NextInt(Random(), 1, numDocs / 5);
     ISet<string> randomTerms = new HashSet<string>();
     while (randomTerms.size() < numTerms)
     {
         randomTerms.add(TestUtil.RandomSimpleString(Random()));
     }
     terms = new List<string>(randomTerms);
     int seed = Random().Next();
     IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(new Random(seed)));
     iwc.SetMergePolicy(TestSortingMergePolicy.NewSortingMergePolicy(sort));
     iw = new RandomIndexWriter(new Random(seed), dir, iwc);
     for (int i = 0; i < numDocs; ++i)
     {
         Document doc = RandomDocument();
         iw.AddDocument(doc);
         if (i == numDocs / 2 || (i != numDocs - 1 && Random().nextInt(8) == 0))
         {
             iw.Commit();
         }
         if (Random().nextInt(15) == 0)
         {
             string term = RandomInts.RandomFrom(Random(), terms);
             iw.DeleteDocuments(new Term("s", term));
         }
     }
     reader = iw.Reader;
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:31,代码来源:TestEarlyTermination.cs


示例17: SetUp

        public override void SetUp()
        {
            base.SetUp();
            dir = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, new MockAnalyzer(Random(), MockTokenizer.WHITESPACE, true), Similarity, TimeZone);

            for (int i = 900; i < 1112; i++)
            {
                Document doc = new Document();
                string num = Regex.Replace(Regex.Replace(English.IntToEnglish(i), "[-]", " "), "[,]", "");
                doc.Add(NewTextField("numbers", num, Field.Store.NO));
                writer.AddDocument(doc);
            }

            {
                Document doc = new Document();
                doc.Add(NewTextField("numbers", "thou hast sand betwixt thy toes", Field.Store.NO));
                writer.AddDocument(doc);
            }
            {
                Document doc = new Document();
                doc.Add(NewTextField("numbers", "hundredeight eightyeight yeight", Field.Store.NO));
                writer.AddDocument(doc);
            }
            {
                Document doc = new Document();
                doc.Add(NewTextField("numbers", "tres y cinco", Field.Store.NO));
                writer.AddDocument(doc);
            }

            writer.Commit();
            writer.Dispose();
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:33,代码来源:TestWordBreakSpellChecker.cs


示例18: AuditLog

        public AuditLog(int DaysToKeepLog, int DaysToKeepRecords)
        {
            string dir = GetDataDirectory();
            _logDays = DaysToKeepLog;
            _recordDays = DaysToKeepRecords;
            Task.Run(() =>
            {
                while (IsFileLocked(new FileInfo($"{dir}/write.lock")))
                {
                    Thread.Sleep(500);
                }
                if (File.Exists($"{dir}/write.lock"))
                    File.Delete($"{dir}/write.lock");
                _dir = FSDirectory.Open(new DirectoryInfo(GetDataDirectory()));

                var reader = GetSearcher();
                var terms = reader.IndexReader.Terms();
                while (terms.Next())
                {
                    if (terms.Term.Field == "content")
                        trie[terms.Term.Text] = terms.Term.Text;
                    if (terms.Term.Field == "user")
                        users.Add(terms.Term.Text);
                }
                ValidateBackup();
            });
        }
开发者ID:JeffDarchuk,项目名称:SitecoreSidekick,代码行数:27,代码来源:AuditLog.cs


示例19: MapReduceIndex

 public MapReduceIndex(Directory directory, int id, IndexDefinition indexDefinition,
                       AbstractViewGenerator viewGenerator, WorkContext context)
     : base(directory, id, indexDefinition, viewGenerator, context)
 {
     jsonSerializer = JsonExtensions.CreateDefaultJsonSerializer();
     jsonSerializer.Converters = MapReduceConverters;
 }
开发者ID:VPashkov,项目名称:ravendb,代码行数:7,代码来源:MapReduceIndex.cs


示例20: RAMDirectory

        private RAMDirectory(Directory dir, bool closeDir)
        {
            System.String[] files = dir.List();
            byte[] buf = new byte[BufferedIndexOutput.BUFFER_SIZE];
            for (int i = 0; i < files.Length; i++)
            {
                // make place on ram disk
                IndexOutput os = CreateOutput(System.IO.Path.GetFileName(files[i]));
                // read current file
                IndexInput is_Renamed = dir.OpenInput(files[i]);
                // and copy to ram disk
                long len = (int) is_Renamed.Length();
                long readCount = 0;
                while (readCount < len)
                {
                    int toRead = readCount + BufferedIndexOutput.BUFFER_SIZE > len ? (int) (len - readCount) : BufferedIndexOutput.BUFFER_SIZE;
                    is_Renamed.ReadBytes(buf, 0, toRead);
                    os.WriteBytes(buf, toRead);
                    readCount += toRead;
                }

                // graceful cleanup
                is_Renamed.Close();
                os.Close();
            }
            if (closeDir)
                dir.Close();
        }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:28,代码来源:RAMDirectory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Store.IndexInput类代码示例发布时间:2022-05-26
下一篇:
C# Vectorhighlight.FieldQuery类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap