一切正常,然后我重新编制了索引,突然3/5节点开始出错。显然,这也导致我的结果中只有2/3能够正常回归。这仅适用于自定义搜索查询。代码和罐子在事物工作和不事件之间发生了变化。
注意:常规过滤的multi_match搜索查询工作正常。
我试过了:
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());
}
}
}