Lucene.Net.Store.FSDirectory.Open C# (CSharp) Method

Open() public static method

Creates an FSDirectory instance, trying to pick the best implementation given the current environment. The directory returned uses the NativeFSLockFactory.

Currently this returns MMapDirectory for most Solaris and Windows 64-bit JREs, NIOFSDirectory for other non-Windows JREs, and SimpleFSDirectory for other JREs on Windows. It is highly recommended that you consult the implementation's documentation for your platform before using this method.

NOTE: this method may suddenly change which implementation is returned from release to release, in the event that higher performance defaults become possible; if the precise implementation is important to your application, please instantiate it directly, instead. For optimal performance you should consider using MMapDirectory on 64 bit JVMs.

See above

public static Open ( DirectoryInfo path ) : FSDirectory
path System.IO.DirectoryInfo
return FSDirectory
        public static FSDirectory Open(DirectoryInfo path)
        {
            return Open(path, null);
        }

Same methods

FSDirectory::Open ( DirectoryInfo path, Lucene.Net.Store.LockFactory lockFactory ) : FSDirectory

Usage Example

示例#1
0
        static void Main(string[] args)
        {
            //Analyzer analyzer = new StandardAnalyzer();
            Analyzer  analyzer  = new StandardAnalyzer(Version.LUCENE_23);
            Directory directory = null;

            //directory.CreateOutput(@"D:\workspace\C#\lucene\lucene\lucene\IndexDirectory");

            while (true)
            {
                Console.Write("id:");
                string id = Console.ReadLine().ToString();
                Console.Write("title:");
                string title = Console.ReadLine().ToString();
                Console.Write("content:");
                string content = Console.ReadLine().ToString();
                Console.WriteLine("=================================");
                string indexPath = @"D:\workspace\C#\lucene\lucene\lucene\IndexDirectory";
                directory = FSDirectory.Open(new System.IO.DirectoryInfo(indexPath));

                IndexWriter writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
                AddDocument(writer, id, title, content);
                writer.Optimize();
                writer.Dispose();
            }
            //AddDocument(writer,"1","name","ada");
            //AddDocument(writer, "2","SQL Server 2008 的发布ada", "SQL Server 2008 的新特性");
            //AddDocument(writer, "3","ASP.Net MVC框架配置与分析", "而今,微软推出了新的MVC开发框架,也就是Microsoft ASP.NET 3.5 Extensions");
        }
All Usage Examples Of Lucene.Net.Store.FSDirectory::Open