elasticsearch 如何在elasticsearch中将lat和lng映射到geo_点类型,elasticsearch,geolocation,nest,elasticsearch,Geolocation,Nest" /> elasticsearch 如何在elasticsearch中将lat和lng映射到geo_点类型,elasticsearch,geolocation,nest,elasticsearch,Geolocation,Nest" />

elasticsearch 如何在elasticsearch中将lat和lng映射到geo_点类型

elasticsearch 如何在elasticsearch中将lat和lng映射到geo_点类型,elasticsearch,geolocation,nest,elasticsearch,Geolocation,Nest,Im使用elasticsearch 7和nest 6.7 我有一个索引,它有任何类型,比如坐标 无论如何,我都有问题 client.CreateIndex("staging2", c => c.Mappings(m => m.Map<VenueIndex>(mm => mm.AutoMap()))); 我的错误在哪里?型号: public class TestClass { public object Promotion { ge

Im使用elasticsearch 7和nest 6.7

我有一个索引,它有任何类型,比如坐标

无论如何,我都有问题

 client.CreateIndex("staging2", c => c.Mappings(m => m.Map<VenueIndex>(mm => mm.AutoMap())));
我的错误在哪里?

型号:

    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; }
    }

你能添加映射吗?@jaspreetchahal你是指邮递员映射?索引映射。如果我是正确的,你的问题是“位置”是用类型float而不是geo_point创建的@jaspreetchahal是的,这是我的问题。Map(mp=>mp.Properties(ps=>ps)。AutoMap()我在这个块中有错误。('CreateIndexDescriptor'不包含'Map'的定义。)我正在使用Nest 7.0。你能试试这个语法var createIndexResponse=\u client.CreateIndex(“myindex”),c=>c.Mappings(ms=>ms.Map(m=>m.AutoMap().AutoMap(typeof(Employee)));这是针对nest6.x的
{
  "isClubMember": false,
 "rating": 0.0,
 "binaryType": 2,
 "location": {
 "lat":"32.11",
 "lon":"-34.22"
 },
   "neighbourhood": "شهرک والفجر,امیر آباد",
   "mealTimes": [],
   "objectID": "188dc91e-8088-4099-9eb8-00aa73653192"}
    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()
                ));
            }
 "gcheck" : {
    "mappings" : {
      "properties" : {
        "binaryType" : {
          "type" : "long"
        },
        "checkin" : {
          "type" : "object"
        },
        "isClubMember" : {
          "type" : "boolean"
        },
        "location" : {
          "type" : "geo_point",
          "ignore_malformed" : true
        },
        "mealTimes" : {
          "type" : "integer"
        },
        "neighbourhood" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "objectID" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "promotion" : {
          "type" : "object"
        },
        "rating" : {
          "type" : "long"
        }
      }
    }
  }