【发布时间】:2018-08-11 08:44:16
【问题描述】:
我正在使用 Nest 6.2.0 连接到弹性搜索。
我正在尝试映射包含 DBGeography 对象的类,并尝试添加 [GeoShape] 标记,但出现以下错误。
ServerError = {ServerError: 400Type: mapper_parsing_exception 原因:“解析失败” CausedBy:“类型:not_x_content_exception 原因:“只能对某些xcontent字节或压缩的xcontent字节调用压缩器检测””}
我用来创建索引和文档的代码是:
// Create an index
response = Connection.CreateIndex(indexName, c => c
.Mappings(ms => ms
.Map<RACE.DataModels.EventModels.Event.Route>(m => m
.AutoMap<RACE.DataModels.EventModels.Event.Route>()
)
)
);
// Add document to index
result = Connection.Index(obj, i => i
.Index(indexName));
另外,这是我试图添加到索引中的 Route 对象的代码。
public partial class Route : BaseClass
{
[Key]
public Guid ID { get; set; }
[Required]
[Display(Name = "Event")]
public Guid EventID { get; set; }
[Required]
[Display(Name = "Route Name")]
public string Name { get; set; }
[Display(Name = "Description")]
public string Description { get; set; }
[Required]
[Display(Name = "Path Type")]
public int PathType { get; set; }
[GeoShape]
[Required]
[Display(Name = "Route Path")]
public DbGeography Path { get; set; }
//[GeoShape]
[Ignore]
public string PathWKT { get { return Path.WellKnownValue.WellKnownText; } }
[GeoShape]
[Display(Name = "Start")]
public DbGeography Start { get; set; }
[GeoShape]
[Display(Name = "End")]
public DbGeography End { get; set; }
[Display(Name = "Laps")]
public int Laps { get; set; }
[Display(Name = "Status")]
public int Status { get; set; }
[Ignore]
[ForeignKey("EventID")]
public virtual Event Event { get; set; }
[Ignore]
[ForeignKey("RouteID")]
public virtual List<Gateway> Gateways { get; set; }
}
DBGeography 是否会阻止对象被正确映射,我如何才能将 DBGeography 对象正确映射到 GeoShape?
【问题讨论】:
标签: c# elasticsearch nest