当使用.net nest client build elasticsearch index的时候 需要 为一些属性加上mapping列入 nest,geopiont
nest mapping
var response = Client.CreateIndex(d => d
.Index(_indexName)
.AddMapping<DishDoc>(m => m
.Type(Constants.TypeName.Dish)
.Properties(p => p
.NestedObject<DishCluster>(n => n
.Name("clusterInfo")
)
)
)
);
class DishDoc
public DishCluster[] ClusterInfo { get; set; }
class DishCluster
[ElasticProperty(Index = FieldIndexOption.No)]
public int Id { get; set; }
[ElasticProperty(Index = FieldIndexOption.No)]
public string Name { get; set; }
geopoint mapping
var response = Client.CreateIndex(d =>
d.Index(Constants.IndexName.Instagram)
.AddMapping<PostDoc>(m => m.Type( Constants.TypeName.Post).MapFromAttributes().Properties(p => p.GeoPoint(g => g.Name(n => n.RegionInfo.Location).IndexLatLon()))));
if (response.ServerError != null)
{
Console.WriteLine(response.ServerError.Error);
}