elasticsearch ElasticSearch Id为null的索引文档失败,elasticsearch,nest,elasticsearch,Nest" /> elasticsearch ElasticSearch Id为null的索引文档失败,elasticsearch,nest,elasticsearch,Nest" />

elasticsearch ElasticSearch Id为null的索引文档失败

elasticsearch ElasticSearch Id为null的索引文档失败,elasticsearch,nest,elasticsearch,Nest,您好: 我正在尝试将此文档编入索引。我目前正在为文档创建做一篇文章: { "name":"facility 3", "types":[ 1 ], "status":1, "registrationDate":"0001-01-01T00:00:00", "capacity":0, "rating":0.0, "licenseStatus":0, "licenseDate":"0001-01-01T00:00:00",

您好:

我正在尝试将此文档编入索引。我目前正在为文档创建做一篇文章:

{  
   "name":"facility 3",
   "types":[  
      1
   ],
   "status":1,
   "registrationDate":"0001-01-01T00:00:00",
   "capacity":0,
   "rating":0.0,
   "licenseStatus":0,
   "licenseDate":"0001-01-01T00:00:00",
   "licenseCloseDate":"0001-01-01T00:00:00",
   "address":"10 thomas avenue*",
   "zipCode":"12345",
   "rentLow":0.0,
   "rentHigh":0.0,
   "basePriceLow":0.0,
   "basePriceHigh":0.0,
   "oneTimeFee":0.0,
   "levelOfCareRangeMinimum":0.0,
   "levelOfCareRangeMaximum":0.0,
   "city":"new york city",
   "state":"New York",
   "facilityManagements":[  
      {  
         "userId":"3e85f416-b00a-407e-a34e-05cec99f38b1",
         "operations":1,
         "isOwner":true,
         "isActive":true,
         "createdDate":"2018-06-29T16:08:19.7700068Z",
         "id":"d7db8c5b-24a2-4a5f-a508-1188233b305f"
      }
   ],
   "facilityRequests":[  
      {  
         "userId":"3e85f416-b00a-407e-a34e-05cec99f38b1",
         "createdDate":"2018-06-29T16:08:19.7709542Z",
         "status":1,
         "id":"77cfa81e-0f62-47ff-8956-b15b7c4321f0"
      }
   ],
   "slug":"facility-3-10-thomas-avenue",
   "approved":false,
   "businessLocation":{  
      "lat":40.7143545,
      "lon":-74.0059735
   },
   "serviceAreas":{  
      "coordinates":[  
         [  
            [  
               0.0,
               0.0
            ]
         ]
      ],
      "type":"polygon"
   },
   "suggest":{  
      "input":[  
         "new york city",
         "New York",
         "facility",
         "3"
      ]
   }
}
但是,这会导致以下错误
id不能为null
。我不明白,因为我以为ES会在这种情况下生成ID。此外,我还使用NEST为映射编制了索引:

  var uri = new Uri(ConfigurationManager.AppSettings["ElasticSearch-Node1"]);
            var pool = new SingleNodeConnectionPool(uri);
            //ElasticSearch Client
            string index = ConfigurationManager.AppSettings["ElasticIndex"];
            return new ConnectionSettings(pool).DefaultIndex(index)
                .DefaultMappingFor<Facility>(m => m.IndexName(index).TypeName("doc"));
var uri=new uri(ConfigurationManager.AppSettings[“ElasticSearch-Node1]”);
var pool=新的SingleNodeConnectionPool(uri);
//ElasticSearch客户端
字符串索引=ConfigurationManager.AppSettings[“ElasticIndex”];
返回新连接设置(池)。默认索引(索引)
.DefaultMappingFor(m=>m.IndexName(index).TypeName(“doc”));

Facility有一组其他内部嵌套对象,这些对象正在与其索引

我认为您的索引映射出现了某种错误,因为当我尝试在本地elasticsearch上索引您的数据时,如果没有任何预定义的方案,它会按预期工作,并自动生成20个字符长、URL安全、Base64编码的GUID字符串ID。请参阅我的工作快照

自动生成ID

如果我们的数据没有自然ID,我们可以让Elasticsearch 自动为我们生成一个。请求的结构发生了变化:取而代之 在使用PUT动词(“将此文档存储在此URL”)时,我们使用 POST动词(“将此文档存储在此URL下”)


请参阅更多信息:

能否显示用于索引文档的代码?