我使用elasticsearch 7和nest 6.7。
我有任何类型的索引,例如坐标。
以任何方式在映射geo_type时我都有问题。
client.CreateIndex("staging2", c => c.Mappings(m => m.Map<VenueIndex>(mm => mm.AutoMap())));
这是我的嵌套代码,这是poko类的som部分:
public object Promotion { get; set; }
public object Checkin { get; set; }
public Featured Featured { get; set; }
public int BinaryType { get; set; }
public List<WorkingHour> WorkingHours { get; set; }
[GeoPoint(Name = "location", IgnoreMalformed = true)]
public Geoloc _geoloc { get; set; }
public string Neighbourhood { get; set; }
public List<int> MealTimes { get; set; }
public string objectID { get; set; }
public class Geoloc
{
[Number(NumberType.Double, Name = "lat")]
public double lat { get; set; }
[Number(NumberType.Double, Name = "lon")]
public double lon { get; set; }
}
通过这种方式,GeoLoc类型为浮点型
当我发布帖子时,其他方式仍然存在此问题。
我的json对象是这样的:
{
"isClubMember": false,
"rating": 0.0,
"binaryType": 2,
"location": {
"lat":"32.11",
"lon":"-34.22"
},
"neighbourhood": "شهرک والفجر,امیر آباد",
"mealTimes": [],
"objectID": "188dc91e-8088-4099-9eb8-00aa73653192"}
我的错误在哪里?
答案 0 :(得分:1)
型号:
node
使用NEST创建映射的代码
public class TestClass
{
public object Promotion { get; set; }
public object Checkin { get; set; }
[GeoPoint(Name = "location", IgnoreMalformed = true)]
public Geoloc _geoloc { get; set; }
public string Neighbourhood { get; set; }
public List<int> MealTimes { get; set; }
public string objectID { get; set; }
}
public class Geoloc
{
[Number(NumberType.Double, Name = "lat")]
public double lat { get; set; }
[Number(NumberType.Double, Name = "lon")]
public double lon { get; set; }
}
输出映射:
var url = "http://localhost:9200";
var settings = new ConnectionSettings(new Uri(url));
EsClient = new ElasticClient(settings);
if (!EsClient.IndexExists("gcheck").Exists)
{
var resp = EsClient.CreateIndex("gcheck", c => c
.Map<TestClass>(mp => mp
.Properties(
ps => ps
).AutoMap()
));
}