gpt4 book ai didi

c# - 使用 geoshape 属性映射创建索引

转载 作者:太空宇宙 更新时间:2023-11-03 10:40:10 25 4
gpt4 key购买 nike

我正在使用 Elasticsearch 的 NEST 客户端库为特定类型创建索引。

该类型包含三个 string 属性和一个用于保存 geo_shape 类型的属性(特别是用于 envelope 形状)。

问题是,生成的请求无法在 ES 中解析:

{
"error": "MapperParsingException[mapping [layer]]; nested: MapperParsingException[No handler for type [point] declared on field [boundingBox]]; ",
"status": 400
}

产生此错误消息的 NEST 构建的请求是:

POST /metadata
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"layer": {
"_all": {
"enabled": false
},
"properties": {
"namespace": {
"type": "string"
},
"name": {
"type": "string"
},
"abstract": {
"type": "string"
},
"boundingBox": {
"type": "point",
"tree": "geohash",
"tree_levels": 2,
"distance_error_pct": 0.025
}
}
}
}
}

我发现唯一阻止这个请求成功的是 boundingBox 属性的 type 声明,它的值应该是 geo_shape 而不是 point

这里是用于执行调用的 C# 代码:

ElasticClient client = new ElasticClient(settings);

IIndicesOperationResponse response = client.CreateIndex(c => c
.Index("metadata")
.NumberOfShards(1)
.NumberOfReplicas(0)
.AddMapping<ESLayer>(m => m
.Type("layer")
.AllField(a => a.Enabled(false))
.Properties(p => p
.String(x => x.Name(n => n.Namespace))
.String(x => x.Name(n => n.Name))
.String(x => x.Name(n => n.Abstract))
.GeoShape(x => x
.Name(n => n.BoundingBox)
.Tree(GeoTree.Geohash)
.TreeLevels(2)
.DistanceErrorPercentage(0.025)))));

ESLayer 类:

private class ESLayer
{
public string Namespace { get; set; }

public string Name { get; set; }

public string Abstract { get; set; }

public EnvelopeGeoShape BoundingBox { get; set; }
}

请注意,我正在使用 NEST 附带的 EnvelopeGeoShape 类来表示边界框属性。

Elasticsearch 版本:1.3.1

NEST 版本:1.0.2

关于我可能遗漏了什么的任何线索?

最佳答案

这肯定是一个错误;不错的收获。我刚打开问题 #925为此并插入了修复。它将包含在我们计划很快发布的下一个版本 (1.1.0) 中。同时,您可以在此处从我们的 CI 构建中获取 NuGet 包:https://www.myget.org/gallery/elasticsearch-net .

关于c# - 使用 geoshape 属性映射创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25675174/

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