Reputation: 401
So, I have an object with an Id
field; when I index it, the resulting document has the _source.id
field as expected, but the _id
field has the same value as _source.id
.
For instance, I have this object:
var obj = new Obj {
...
Id = 'some_value',
...
};
After indexing, I see that the ES document is like so:
{
...
"_id: "some_value",
...
"_source" : {
...
"id" : "some_value",
...
}
}
The question is: is it possible to somehow disable this behavior? like, how can I let Elasticsearch generate the value for _id
(if possible)?
Upvotes: 1
Views: 1516
Reputation: 125508
This is a feature known as Id inference. If you would prefer NEST not do it, I would recommend either
Id
property on the POCO to something elseElasticsearchType
and assign a non-existent property name to IdProperty
[ElasticsearchType(IdProperty = "do_not_infer_id")]
public class MyDocument
{
public int Id { get; set; }
}
Upvotes: 3