Example #1
0
        public virtual void DoTestUndeleteAll()
        {
            Sis.Read(Dir);
            IndexReader reader = OpenReader();

            Assert.IsTrue(reader != null);
            Assert.AreEqual(2, reader.NumDocs());
            reader.DeleteDocument(0);
            Assert.AreEqual(1, reader.NumDocs());
            reader.UndeleteAll();
            Assert.AreEqual(2, reader.NumDocs());

            // Ensure undeleteAll survives commit/close/reopen:
            reader.Commit();
            reader.Close();

            if (reader is MultiReader)
            {
                // MultiReader does not "own" the directory so it does
                // not write the changes to sis on commit:
                Sis.Commit(Dir);
            }

            Sis.Read(Dir);
            reader = OpenReader();
            Assert.AreEqual(2, reader.NumDocs());

            reader.DeleteDocument(0);
            Assert.AreEqual(1, reader.NumDocs());
            reader.Commit();
            reader.Close();
            if (reader is MultiReader)
            {
                // MultiReader does not "own" the directory so it does
                // not write the changes to sis on commit:
                Sis.Commit(Dir);
            }
            Sis.Read(Dir);
            reader = OpenReader();
            Assert.AreEqual(1, reader.NumDocs());
        }
Example #2
0
        /// <summary>
        /// 从资讯索引中将索引删除
        /// </summary>
        /// <param name="IDList">需要删除索引的资讯的ID列表(以 , 隔开)</param>
        public static void MusicDelete(string IDList)
        {
            string[]    arrMusicID = IDList.Split(',');
            IndexReader reader     = IndexReader.Open(FSDirectory.Open(indexPath), false);

            for (int i = 0, len = arrMusicID.Length; i < len; i++)
            {
                Term term = new Term("Number", arrMusicID[i]);
                reader.DeleteDocuments(term);
            }
            reader.Commit();
            reader.Dispose();
        }
 protected internal override void DoCommit(System.Collections.Generic.IDictionary <string, string> commitUserData)
 {
     in_Renamed.Commit(commitUserData);
 }