示例#1
0
        /// <summary> Returns <code>true</code> iff the index in the named directory is
        /// currently locked.
        /// </summary>
        /// <param name="directory">the directory to check for a lock
        /// </param>
        /// <throws>  IOException if there is a problem with accessing the index </throws>
        public static bool IsLocked(System.String directory)
        {
            Directory dir    = FSDirectory.GetDirectory(directory, false);
            bool      result = IsLocked(dir);

            dir.Close();
            return(result);
        }
示例#2
0
        /// <summary> Reads version number from segments files. The version number counts the
        /// number of changes of the index.
        ///
        /// </summary>
        /// <param name="directory">where the index resides.
        /// </param>
        /// <returns> version number.
        /// </returns>
        /// <throws>  IOException if segments file cannot be read </throws>
        public static long GetCurrentVersion(System.IO.FileInfo directory)
        {
            Directory dir     = FSDirectory.GetDirectory(directory, false);
            long      version = GetCurrentVersion(dir);

            dir.Close();
            return(version);
        }
示例#3
0
 /// <summary>Returns an IndexReader reading the index in an FSDirectory in the named
 /// path.
 /// </summary>
 public static Monodoc.Lucene.Net.Index.IndexReader Open(System.IO.FileInfo path)
 {
     return(Open(FSDirectory.GetDirectory(path, false), true));
 }
示例#4
0
 /// <summary> Returns the time the index in the named directory was last modified.
 ///
 /// <p>Synchronization of IndexReader and IndexWriter instances is
 /// no longer done via time stamps of the segments file since the time resolution
 /// depends on the hardware platform. Instead, a version number is maintained
 /// within the segments file, which is incremented everytime when the index is
 /// changed.</p>
 ///
 /// </summary>
 /// <deprecated>  Replaced by {@link #GetCurrentVersion(File)}
 ///
 /// </deprecated>
 public static long LastModified(System.IO.FileInfo directory)
 {
     return(FSDirectory.FileModified(directory, "segments"));
 }
 /// <summary> Constructs an IndexWriter for the index in <code>path</code>.
 /// Text will be analyzed with <code>a</code>.  If <code>create</code>
 /// is true, then a new, empty index will be created in
 /// <code>path</code>, replacing the index already there, if any.
 ///
 /// </summary>
 /// <param name="path">the path to the index directory
 /// </param>
 /// <param name="a">the analyzer to use
 /// </param>
 /// <param name="create"><code>true</code> to create the index or overwrite
 /// the existing one; <code>false</code> to append to the existing
 /// index
 /// </param>
 /// <throws>  IOException if the directory cannot be read/written to, or </throws>
 /// <summary>  if it does not exist, and <code>create</code> is
 /// <code>false</code>
 /// </summary>
 public IndexWriter(System.IO.FileInfo path, Analyzer a, bool create) : this(FSDirectory.GetDirectory(path, create), a, create, true)
 {
 }