Reputation: 1213
I am using Nest Client to communicate with ElasticSearch.
When i trying to index child type it is giving me error in the heading. I have already set this attribute on Parent Type : [ElasticType(Name ="item", IdProperty = "id")]. This should tell elastic type about id field.
Below is the query made by nest with error info.
{StatusCode: 400,
Method: PUT,
Url: http://localhost:9200/itemindex/inventory/15894?routing=15894&parent=15894,
Request: {
"itemId": 15894,
"inventories": [
{
"storeId": 20693,
"inventoryCount": 40
}
]
}
Response: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Can't specify parent if no parent field has been configured"}],"type":"illegal_argument_exception","reason":"Can't specify parent if no parent field has been configured"},"status":400}}
When i am using this query directly with sense. It is successfully inserting and updating data. But not when i try with Nest.
Please suggest? Any help is appreciated. Thank you in advance.
Could any one explain the reason of this error?
Upvotes: 2
Views: 6054
Reputation: 9979
I don't know your index mapping, but looks like you forgot to specify parent when defining mapping for child document.
This is how you can do this with NEST 2.0.0-alpha1.
public class Parent
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Child
{
public int Id { get; set; }
public string Name { get; set; }
}
var response = client.CreateIndex(indexName, d => d
.Mappings(map => map
.Map<Parent>(m => m.AutoMap())
.Map<Child>(m => m.AutoMap().Parent<Parent>())));
Hope it helps.
Upvotes: 1