不知道错误在哪里,但这就是我遇到的问题。以下代码(经过GeoShape过滤的查询):
List<List<double>> gs_polygone_quiberon = new List<List<double>>() {
new List<double>() {-3.183515, 47.542491}
, new List<double>(){-3.095624, 47.537624}
, new List<double>(){-3.026788, 47.478487}
, new List<double>() {-3.190896, 47.452956}
, new List<double>() {-3.183515, 47.542491}
};
var results = client.Search<Elastic_Oi>(s => s
.AllIndices()
.From(0)
.AllTypes()
.Size(10)
.Query(q => q.Filtered(
f => f.Filter(x =>
x.GeoShape("GeoShapeLocation", d => d.Type("polygon").Coordinates(gs_polygone_quiberon))
)
)
)
);
生成以下JSon:
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"filter": {
"geo_shape": {
"GeoShapeLocation": {
"shape": {
"type": "polygon",
"coordinates": [
[
-3.183515,
47.542491
],
[
-3.095624,
47.537624
],
[
-3.026788,
47.478487
],
[
-3.190896,
47.452956
],
[
-3.183515,
47.542491
]
]
}
}
}
}
}
}
}
在NEST中出现400错误。
直接在ES中执行Json会生成空指针异常。为了能够执行查询,我必须在“坐标”字段中添加一个缩进级别,就像下面的Json一样(我将所有“坐标”字段值都包装在[]中)
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"filter": {
"geo_shape": {
"GeoShapeLocation": {
"shape": {
"type": "polygon",
"coordinates": [[
[
-3.183515,
47.542491
],
[
-3.095624,
47.537624
],
[
-3.026788,
47.478487
],
[
-3.190896,
47.452956
],
[
-3.183515,
47.542491
]
]]
}
}
}
}
}
}
}
此查询的工作原理很简单,但无法使用Nest进行重现,Coordinates
GeoShape过滤器的方法采用IEnumerable<IEnumerable<double>>
参数,而不是IEnumerable<IEnumerable<IEnumerable<double>>>
参数。
是Nest中的错误吗?我的代码?ES?
提前致谢 !
麦克风
“回答”我自己的问题。这确实是NEST中的一个错误,正如我们在NEST作者评论中所见,https://github.com/elasticsearch/elasticsearch-net/issues/776
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句