本文整理汇总了Python中search.Search.refresh_index方法的典型用法代码示例。如果您正苦于以下问题:Python Search.refresh_index方法的具体用法?Python Search.refresh_index怎么用?Python Search.refresh_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search.Search
的用法示例。
在下文中一共展示了Search.refresh_index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import refresh_index [as 别名]
def test_search(self):
# Create search interface and reset the index
s = Search()
s.reset_index()
# Create a couple of objects and add them to the index
testa = models.SearchTest()
testa.title = "Hello World"
testa.save()
s.add(testa)
testb = models.SearchTest()
testb.title = "Hello"
testb.save()
s.add(testb)
testc = models.SearchTestChild()
testc.title = "Hello"
testc.save()
s.add(testc)
# Refresh index
s.refresh_index()
# Ordinary search
results = s.search("Hello", models.SearchTest)
self.assertEqual(len(results), 3)
# Ordinary search on "World"
results = s.search("World", models.SearchTest)
self.assertEqual(len(results), 1)
# Searcher search
results = models.SearchTest.title_search("Hello")
self.assertEqual(len(results), 3)
# Ordinary search on child
results = s.search("Hello", models.SearchTestChild)
self.assertEqual(len(results), 1)
# Searcher search on child
results = models.SearchTestChild.title_search("Hello")
self.assertEqual(len(results), 1)