|
|
|
@ -60,11 +60,6 @@ namespace Volo.Docs.Documents.FullSearch.Elastic
|
|
|
|
|
|
|
|
|
|
var client = _clientProvider.GetClient();
|
|
|
|
|
|
|
|
|
|
var existsResponse = await client.DocumentExistsAsync(DocumentPath<EsDocument>.Id(document.Id),
|
|
|
|
|
x => x.Index(_options.IndexName), cancellationToken);
|
|
|
|
|
|
|
|
|
|
HandleError(existsResponse);
|
|
|
|
|
|
|
|
|
|
var esDocument = new EsDocument
|
|
|
|
|
{
|
|
|
|
|
Id = NormalizeField(document.Id),
|
|
|
|
@ -76,17 +71,7 @@ namespace Volo.Docs.Documents.FullSearch.Elastic
|
|
|
|
|
Version = NormalizeField(document.Version)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!existsResponse.Exists)
|
|
|
|
|
{
|
|
|
|
|
HandleError(await client.IndexAsync(esDocument,
|
|
|
|
|
x => x.Id(document.Id).Index(_options.IndexName), cancellationToken));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HandleError(await client.UpdateAsync(DocumentPath<EsDocument>.Id(document.Id),
|
|
|
|
|
x => x.Doc(esDocument).Index(_options.IndexName), cancellationToken));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await client.IndexAsync(esDocument , x=>x.Index(_options.IndexName), cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task DeleteAsync(Guid id, CancellationToken cancellationToken = default)
|
|
|
|
@ -94,7 +79,7 @@ namespace Volo.Docs.Documents.FullSearch.Elastic
|
|
|
|
|
ValidateElasticSearchEnabled();
|
|
|
|
|
|
|
|
|
|
HandleError(await _clientProvider.GetClient()
|
|
|
|
|
.DeleteAsync(DocumentPath<Document>.Id(id), x => x.Index(_options.IndexName), cancellationToken));
|
|
|
|
|
.DeleteAsync(DocumentPath<Document>.Id( NormalizeField(id)), x => x.Index(_options.IndexName), cancellationToken));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task DeleteAllAsync(CancellationToken cancellationToken = default)
|
|
|
|
|