gpt4 book ai didi

c# - 可能是GeoShape过滤器(NEST)中的错误

转载 作者:行者123 更新时间:2023-12-02 23:39:39 25 4
gpt4 key购买 nike

不知道错误在哪里,但这就是我遇到的问题。
以下代码(经过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会生成空指针异常。为了能够执行查询,我必须在“coordinates”字段中添加一个缩进级别,就像下面的Json一样(我将所有“coordinates”字段值都包装在[]中)
{
"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进行重现,GeoShape过滤器的 Coordinates方法采用 IEnumerable<IEnumerable<double>>参数,而不是 IEnumerable<IEnumerable<IEnumerable<double>>>参数。

是Nest中的错误吗?我的代码? ES?

提前致谢 !

麦克风

最佳答案

“回答”我自己的问题。这确实是NEST中的一个错误,正如我们在NEST作者评论https://github.com/elasticsearch/elasticsearch-net/issues/776中可以看到的那样

关于c# - 可能是GeoShape过滤器(NEST)中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24694913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com