- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 Python API 创建 Elasticsearch 索引,如下所示:
from elasticsearch import Elasticsearch
es = Elasticsearch()
index_body = {"mappings": {".percolator": {"properties": {"message": {"type": "string", "analyzer": "english"}}}}}
# Creates the index if it doesn't exist
if not es.indices.exists('test'):
es.indices.create(index='test', body=index_body)
print es.exists(index='test', id='1')
索引已成功创建,但是当我检查索引中是否存在文档时,它失败并出现以下错误:
Traceback (most recent call last):
File "main.py", line 12, in <module>
print es.exists(index='test', id='1')
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 68, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/__init__.py", line 282, in exists
self.transport.perform_request('HEAD', _make_path(index, doc_type, id), params=params)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py", line 307, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py", line 86, in perform_request
self._raise_error(response.status, raw_data)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py", line 102, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: TransportError(503, u'')
如果我第二次运行这个脚本,在索引已经创建的情况下它工作得很好。有没有人知道可能出了什么问题?
最佳答案
创建新索引时,需要等到所有分片分配完毕。
我知道的最好的方法是:
<your_index>/_status
indices.<your_index>.shards
并验证 routing.state = STARTED
无处不在Here's a (PHP) project这是为单元测试做的:
protected function _waitForAllocation(Index $index)
{
do {
$settings = $index->getStatus()->get();
$allocated = true;
foreach ($settings['shards'] as $shard) {
if ($shard[0]['routing']['state'] != 'STARTED') {
$allocated = false;
}
}
} while (!$allocated);
}
错误答案:
在继续之前,您必须给 ES 一些空间。 ES 接近实时,因此可能会有延迟。尤其是当您几乎没有延迟地按顺序运行代码时。
我想你只需要调用 _refresh
endpoint你被覆盖了。
在实践中,我必须在我的单元测试中做同样的事情。它们执行得非常快,创建/提取数据/销毁索引需要时间,因此在我的 setUp()
中我调用 _refresh
在移交给各自的test*()
之前方法。在一些测试中,我索引数据的地方,我也必须放置 _refresh
电话。
通常,在正常操作期间,您不需要调用它。请记住,默认 refresh_interval
是1s
.如果您定期更新索引并希望反射(reflect)亚秒级更新(我说的是例如 _search
),这就是您需要开始的地方。
关于python - 尝试使用最近创建的 Elasticsearch 索引时出现 TransportError(503, u''),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30082240/
我想显示阿拉伯文字,但字符 المملك 显示。 例如,在 المملكة العربية السعودية 上显示单词 المملك٩ ا
我的应用程序正在 java + MSSQL 和 MySQL 上运行。下面的查询适用于 MSSQL,但不适用于 MySql。在 mysql 中,当我编写如下查询时,它给出了错误的结果 查询 select
根据 is_destructible 的定义( http://eel.is/c++draft/meta.unary.prop#lib:is_destructible ), is_destructib
我有一个数据库表,其中有一列我对波斯字母进行了分类,以便稍后使用 MySQL WHERE 选择。一切都适用于所有字母,但我在选择在数据库中存储为 (Ù†) 的字母 (?) 和存储为 (Ú†) 的 (?
我知道像这样的可选链接: someOptional?.someProperty 基本上是 someOptional.map { $0.someProperty } 但是,我发现同时做这两件事是不可能的
u-boot配置文件中的以下配置我看不懂 CONFIG_SYS_EXTRA_OPTIONS="SYS_SDRAM_SIZE=0x20000000" 好像在 u-boot 代码中设置 DRAM 大小。但
我对以下两个方法声明感到困惑: private T funWorks(T child, U parent) { // No compilation errors }
给定如下 API: class Bar { ... } class Foo extends Bar { ... } 在 Java 的 Optional 类型中,我们可以说: Optional fooO
我有一个文件,每行有两个字符: $ cat roman Ⅱ Ⅲ nut 当我用 sort -u 对这个文件进行排序时,只显示一行: $ sort -u roman Ⅱ Ⅱ是代码点U+2161,Ⅲ是代码
我正在尝试将 C 数组分配给 C++ std::array。 我该如何做到这一点,最干净的方式并且不制作不需要的拷贝等? 什么时候做 int X[8]; std::array Y = X; 我得到一个
我有以下案例类: case class [Q Length[T] 但是,我收到一条错误消息,说 需要三个参数,而我只给出了两个。我希望它像这样工作: type Area[T] = [Length[T
它是 well documented那个[T; n]可以强制到[T] .下面的代码也是well-formed : fn test(){ let _a: &[i32] = &[1, 2, 3];
我正在尝试使用 tweepy 在 Tkinter 窗口上显示我的 Twitter 时间线。这是代码 import tweepy import tkinter consumer_key = 'xxxxx
我正在使用以下包含 letter ü 的文本片段: test für fur test 代码如下: import re for m in re.finditer(r, line, re.IGNOREC
我对 USQL 很陌生,想知道如何在 select 语句中将“日期时间”转换为“日期”。另外,我如何摆脱毫秒和上午/下午?我真的很感激这方面的任何帮助。谢谢你们。 最佳答案 下面是有效的代码。注意括号
在 U-SQL 自定义代码(代码隐藏或程序集)中可以调用外部服务,例如bing搜索或 map 。 谢谢, 纳西尔 最佳答案 由于以下原因,目前不支持此功能: 想象一下,您编写了一个 UDF 或 UDO
我想 ping 出多个以太网端口。 u-boot 仅支持单个以太网端口是否存在固有限制? 最佳答案 Can u-boot support more than one ethernet port? 是的
我最近开始学习Prolog,但无法解决如何将三个列表合并的问题。 我能够合并两个列表: %element element(X,[X|_]). element(X,[_|Y]):-
我们使用 Beaglebone 黑色定制板。我编辑了一个链接器脚本文件以添加内存部分以在其中记录一些信息: . = ALIGN(4); .logging : { _log_begin
我们使用 Beaglebone 黑色定制板。我编辑了一个链接器脚本文件以添加内存部分以在其中记录一些信息: . = ALIGN(4); .logging : { _log_begin
我是一名优秀的程序员,十分优秀!