frankm
(Frank Mehlhop)
April 8, 2019, 11:09am
1
To avoid duplicates I like to give a document ID to each data set into Elastic.
As described at the documentation I like to set a ID while adding a item to Elastic. The description recommend to set the ID like this:
PUT /{index}/{type}/{id}
But I'm using the ElasticClient and I'm adding items like this:
ElasticClient.IndexDocumentAsync(doc);
I don't know how to set the Index here. I thought about some thing like
ElasticClient.SetId(id);
but I cant find a method like that.
How can I add the ID using the IElasticClient object?
pjanzen
(Paul Janzen)
April 8, 2019, 11:18am
2
Assuming you are using java to index documents, the docs are here
frankm
(Frank Mehlhop)
April 8, 2019, 11:19am
3
I'm using C# .NET .
To set the Id I extend my _doc class with the property Id .
Than I set the Id .
doc.Id = myId;
ElasticClient.IndexDocumentAsync(doc);
So I don't get any duplicates at the Elastic anymore.
system
(system)
Closed
May 6, 2019, 11:19am
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.