【发布时间】:2017-08-16 21:42:32
【问题描述】:
我在我的项目中使用 Python 中的 elasticsearch-dsl 包。我有一个非常简单的搜索查询,如下所示:
s = Search(using=connections.get_connection(), index= 'registry', doc_type=['storage_doc']).params(request_timeout=60)
s.filter("match", postcode="SW1").query("match", forename="Brendan")
response = s.execute(ignore_cache=True)
print(response.success())
print(response.took)
print(response.to_dict())
print('Total %d hits found.' % response.hits.total)
如果我在调试模式下执行它可以正常工作,但是当我从控制台运行代码时,我总是得到 0 次点击。我不知道为什么会这样,我已经花了半天时间试图找到解决方案。有什么想法吗?
【问题讨论】:
-
“调试模式”是什么意思?
-
我正在使用 VS Code 并对此进行调试。如果我处于调试模式,那么它可以工作。如果我运行 python
那么它不是。真奇怪 -
我对那个 IDE 了解不多,但是您的连接定义是否可能以某种方式在您的 IDE 中设置?可能值得在控制台上使用
pdb逐步完成此操作。
标签: python elasticsearch elasticsearch-dsl elasticsearch-dsl-py