一切正常,然后我重新索引了一些东西,突然 3/5 个节点开始出错。显然,这也导致我只有 2/3 的结果能够正常返回。这仅发生在自定义搜索查询中。代码和 jar 在事情正常和不正常之间发生了变化。
注意:常规过滤的 multi_match 搜索查询工作正常。
我努力了:
- 删除所有索引并重新索引所有数据
- 停止和启动 Elasticsearch
- 重新编译我的自定义脚本
- 尝试了 50 多次搜索查询(一半使用 Java,一半使用 CURL)
Pastebin 是控制台中出现的错误:http: //pastebin.com/1iq3M6fk
正在执行搜索查询(这已经工作了好几天了,并且没有受到影响):
{
"query": {
"custom_score": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"script": "customscript",
"params": {
"lat": 40.76405282025,
"lon": -73.972994269042
},
"lang": "native"
}
}
}
以下是我在执行上述查询时得到的响应:
{
"took": 225,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 2,
"failed": 3,
"failures": [
{
"status": 500,
"reason": "RemoteTransportException[Failed to deserialize exception response from stream]; nested: TransportSerializationException[Failed to deserialize exception response from stream]; nested: StreamCorruptedException[unexpected end of block data]; "
},
{
"status": 500,
"reason": "RemoteTransportException[Failed to deserialize exception response from stream]; nested: TransportSerializationException[Failed to deserialize exception response from stream]; nested: StreamCorruptedException[unexpected end of block data]; "
},
{
"status": 500,
"reason": "RemoteTransportException[Failed to deserialize exception response from stream]; nested: TransportSerializationException[Failed to deserialize exception response from stream]; nested: StreamCorruptedException[unexpected end of block data]; "
}
]
},
"hits": {
"total": 548,
"max_score": 16.027588,
"hits": [
{
...
}
]
}
}
以下是上述查询中使用的自定义脚本(它也有一个工厂):
import org.elasticsearch.common.Nullable;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.NativeScriptFactory;
import org.elasticsearch.script.AbstractDoubleSearchScript;
import org.elasticsearch.index.mapper.geo.GeoPointDocFieldData;
import java.util.Collection;
import java.util.Map;
import java.io.IOException;
import java.lang.Math;
public class CityMapsCustomScript extends AbstractDoubleSearchScript {
double lat;
double lon;
public CityMapsCustomScript(@Nullable Map<String, Object> params) {
lat = ((Double) params.get("lat")).doubleValue();
lon = ((Double) params.get("lon")).doubleValue();
}
@Override
public double runAsDouble() {
double distance = ((GeoPointDocFieldData) doc().field("location")).distance(lat, lon);
String str = doc().field("_type").getStringValue();
float score = score();
if (str.equals("business")) {
return -distance + (double) score;
} else {
return Double.parseDouble(doc().field("_boost").getStringValue());
}
}
}