根据AWS官方文档提供的示例代码,通过手动指定相应的图像处理参数以及更新附件的元数据,可以调整附件处理方式,从而解决摄取附件处理不一致的问题。下面是一个示例代码段:
var response = await client.IndexAsync(indexName, document);
if (response.IsValid)
{
var result = response.Result;
var attachment = document.DownloadAttachment();
var updatedAttachment = new Attachment(attachment.ContentType, attachment.Content);
updatedAttachment.Metadata.Add("DocumentType", "report");
updatedAttachment.Metadata.Add("Author", "John Doe");
updatedAttachment.Metadata.Add("CreatedDate", DateTime.UtcNow.ToString("u"));
var updateRequestParameters = new UpdateRequestParameters
{
ContentType = attachment.ContentType,
ContentLength = attachment.Content.Length,
Pipeline = "attachment",
Routing = attachment.DocumentId
};
await client.UpdateAsync(attachment, update => update
.Doc(new
{
Attachment = updatedAttachment,
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(document.Content))
})
.RequestParameters(updateRequestParameters));
}