Skip to content

Latest commit

 

History

History
60 lines (38 loc) · 1.55 KB

delete.markdown

File metadata and controls

60 lines (38 loc) · 1.55 KB
template title menusection menuitem
layout.jade
Connecting
core
delete

Deleting

The delete API allows to delete a typed JSON document from a specific index based on its id. See also deleting by query for other ways to delete data.

By Id

this.ConnectedClient.Delete<ElasticSearchProject>(searchProject.Id);
this.ConnectedClient.DeleteAsync<ElasticSearchProject>(searchProject.Id);

Delete with custom parameters

_client.Delete(request.Id, s => s
	.Type("users")
	.Index("myindex")
);

By object (T)

Id property is inferred (can be any value type (int, string, float ...))

this.ConnectedClient.Delete(searchProject);
this.ConnectedClient.DeleteAsync(searchProject);

By IEnumerable

this.ConnectedClient.DeleteMany(searchProjects);
this.ConnectedClient.DeleteManyAsync(searchProjects);

By IEnumerable using bulkparameters

Using bulk parameters you can control the deletion of each individual document further

		var bulkedProjects = searchProjects
			.Select(d=> new BulkParameters<ElasticSearchProject>(d) 
			{ 
				Version = d.Version, 
				VersionType = VersionType.External 
			}
		);
        this.ConnectedClient.DeleteMany(bulkedProjects, new SimpleBulkParameters() { Refresh = true });

By Query

Please see deleting by query

Indices and Mappings

Please see delete mapping

and delete index