本文整理汇总了Python中index.Index.create方法的典型用法代码示例。如果您正苦于以下问题:Python Index.create方法的具体用法?Python Index.create怎么用?Python Index.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类index.Index
的用法示例。
在下文中一共展示了Index.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_index_file
# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import create [as 别名]
def test_index_file():
dir = './test_index'
idx = Index.create(dir)
writer = idx.get_writer()
writer.add_document(
path = u'/foo/bar',
title = u'Foo: The History',
last_modified = 34343423423,
text = u'Not much to say here')
writer.commit()
assert idx.doc_count() == 1
示例2: createIndex
# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import create [as 别名]
def createIndex(self, name, col):
""" Create an index on the table.
Arguments:
name -- name of the index, used to identify it
col -- name of column to be used as key for the index
"""
index = Index.create(name, col)
self.indexes.append(index)
for row in self.rows:
index.insert(row)
示例3: test_documents_found_by_title
# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import create [as 别名]
def test_documents_found_by_title():
idx = Index.create('./test_index')
indexer = DirectoryIndexer(idx)
indexer.index_directory('./tests/sample_files')
searcher = Searcher(idx)
assert 1 == len(searcher.find_by_title(u'one'))
示例4: test_documents_found_by_full_text
# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import create [as 别名]
def test_documents_found_by_full_text():
idx = Index.create('./test_index')
indexer = DirectoryIndexer(idx)
indexer.index_directory('./tests/sample_files')
searcher = Searcher(idx)
assert 2 == len(searcher.find_by_full_text(u'Funny'))
示例5: test_documents_added
# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import create [as 别名]
def test_documents_added():
idx = Index.create('./test_index')
indexer = DirectoryIndexer(idx)
indexer.index_directory('./tests/sample_files')
assert idx.doc_count() == 3
示例6: test_index_exists
# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import create [as 别名]
def test_index_exists():
dir = './test_index'
Index.create(dir)
assert Index.exists(dir)
示例7: test_new_index_has_zero_documents
# 需要导入模块: from index import Index [as 别名]
# 或者: from index.Index import create [as 别名]
def test_new_index_has_zero_documents():
dir = './test_index'
idx = Index.create(dir)
assert idx.doc_count() == 0