|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Elasticsearch.Net; |
|
|
|
@ -69,7 +70,24 @@ namespace Volo.Docs.Documents.FullSearch.Elastic |
|
|
|
Version = NormalizeField(document.Version) |
|
|
|
}; |
|
|
|
|
|
|
|
await client.IndexAsync(esDocument, x => x.Index(_options.IndexName), cancellationToken); |
|
|
|
HandleError(await client.IndexAsync(esDocument, x => x.Index(_options.IndexName), cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task AddOrUpdateManyAsync(IEnumerable<Document> documents, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var client = _clientProvider.GetClient(); |
|
|
|
|
|
|
|
var esDocuments = documents.Select(x => new EsDocument { |
|
|
|
Id = NormalizeField(x.Id), |
|
|
|
ProjectId = NormalizeField(x.ProjectId), |
|
|
|
Name = x.Name, |
|
|
|
FileName = x.FileName, |
|
|
|
Content = x.Content, |
|
|
|
LanguageCode = NormalizeField(x.LanguageCode), |
|
|
|
Version = NormalizeField(x.Version) |
|
|
|
}); |
|
|
|
|
|
|
|
HandleError(await client.IndexManyAsync(esDocuments, _options.IndexName, cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task DeleteAsync(Guid id, CancellationToken cancellationToken = default) |
|
|
|
|