当前位置: 首页>>代码示例>>Python>>正文


Python DirectoryReader.listCommits方法代码示例

本文整理汇总了Python中org.apache.lucene.index.DirectoryReader.listCommits方法的典型用法代码示例。如果您正苦于以下问题:Python DirectoryReader.listCommits方法的具体用法?Python DirectoryReader.listCommits怎么用?Python DirectoryReader.listCommits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.index.DirectoryReader的用法示例。


在下文中一共展示了DirectoryReader.listCommits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testIndexDeletionPolicy

# 需要导入模块: from org.apache.lucene.index import DirectoryReader [as 别名]
# 或者: from org.apache.lucene.index.DirectoryReader import listCommits [as 别名]
    def testIndexDeletionPolicy(self):

        writer = self.getWriter()

        # no commits exist in the index yet
        self.assertTrue(self.policy.onInitCalled)
        # we haven't called commit yet
        self.assertFalse(self.policy.onCommitCalled)

        doc = Document()
        writer.addDocument(doc)
        writer.commit()

        # now we called commit
        self.assertTrue(self.policy.onCommitCalled)

        # external IR sees 1 commit:
        self.assertEquals(1, DirectoryReader.listCommits(self.directory).size())

        # commit again:
        writer.addDocument(doc)
        writer.commit()

        # external IR sees 2 commits:
        self.assertEquals(2, DirectoryReader.listCommits(self.directory).size())

        writer.close()

        # open same index, make sure both commits survived:
        writer = self.getWriter()

        self.assertTrue(self.policy.onInitCalled)
        self.assertFalse(self.policy.onCommitCalled)
        self.assertEquals(2, DirectoryReader.listCommits(self.directory).size())
        writer.close()

        # 3 from closing writer again
        self.assertEquals(3, DirectoryReader.listCommits(self.directory).size())
开发者ID:svn2github,项目名称:pylucene,代码行数:40,代码来源:test_IndexDeletionPolicy.py


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