美好的一天:
我正在尝试将此文档文档编入ES。我目前正在为文档创建执行 POST :
{
"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 must not be 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"));
该设施还有一堆其他内部嵌套的对象,这些对象正以此索引。
答案 0 :(得分:0)
我认为您的索引映射存在某种错误,因为当我尝试使用您的数据在没有任何预定义方案的情况下在本地Elasticsearch上对其进行索引时,它就可以按预期工作,并且会自动生成20个字符长的URL-安全的,Base64编码的GUID字符串ID。查看我的工作快照
自动生成ID
如果我们的数据没有自然ID,我们可以让Elasticsearch 为我们自动生成一个。请求的结构更改: 使用PUT动词(“将文档存储在此URL”)的过程中, POST动词(“将此文档存储在此URL下”)。
查看更多:https://www.elastic.co/guide/en/elasticsearch/guide/current/index-doc.html#_autogenerating_ids