我是django-haystack
和elasticsearch
返回的功能测试结果。你知道吗
我在做测试时得到了不同的结果。有时考试及格,有时不及格
我不明白为什么会这样。你知道吗
我的测试类首先在测试数据库中创建条目,然后使用StaticLiveServerTestCase安装方法调用manage.py rebuild_index
。最后我称之为manage.py clear_index
。你知道吗
我不会在这里复制搜索索引的所有django代码_文本.txt因为django haystack/elasticsearch代码正在运行。你知道吗
我想知道创建的数据库条目和对rebuild_index
的调用之间是否存在同步问题。你知道吗
基本上,在我的测试中我是这样做的
class SearchTest(FunctionalTest):
def setUp(self):
super(SearchTest, self).setUp() # this make the entries in database
self.rebuild_index()
def tearDown(self):
super(SearchTest, self).tearDown()
call_command('clear_index', interactive=False)
打印索引对象有时会得到不正确的结果:
<QuerySet [<Step: emg>]>
<QuerySet [<Step: emg>]>
<QuerySet [<Step: emg>]>
有时,正确的方法是:
<QuerySet [<Step: emg>]>
<QuerySet [<Step: emg>]>
<QuerySet [<Step: emg>]>
<QuerySet [<Step: eeg>, <Step: emg>]>
<QuerySet [<Step: eeg>, <Step: emg>]>
那么,会发生什么?你知道吗
你在标题处说答案。”不确定性“,首先你需要了解这是什么。对于相同的输入,非确定性算法可以得到不同的结果。但为什么会这样?你知道吗
如果你还记得为什么我们使用非确定性算法,你就会找到解决方案。一般来说,非确定性算法需要比确定性算法更快,为此,它们可以“广义化”一些东西(比如数学中的近似),这种广义化可以得到不同的结果。但是,真的很快:)
阅读更多关于Nondeterministic algorithms
编辑:也许elasticsearch或django haystack有一些确定性搜索的配置
相关问题 更多 >
编程相关推荐