Same question can also be found at Stackoverflow: http://stackoverflow.com/questions/42786319/how-to-use-the-attachment-processor-within-an-array-of-attachments
Description of problem
I want to use the attachment processor within an array of attachments. I am aware of the fact that the foreach processor is required for this purpose.
This enables the attachment processor to be run on the individual elements of the array (https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment-with-arrays.html)
I am using the Elasticsearch NEST client and I am not finding any good examples where someone use the foreach processor with an attachment processor within an array of attachments.
Now, I have this code, but it does not work:
public async Task IndexDocument(Guid applicationId, Guid projectId, ApplicationDto application)
{
var indexName = string.Format(ElasticsearchIndexName, projectId);
await _client.PutPipelineAsync("attachments", p => p
.Description("Document attachments pipeline")
.Processors(pr => pr
.Foreach<ApplicationDto>(fch => fch
.Field(f => f.Files)
.Processor(pcsr => pcsr
.Attachment<Attachment>(a => a
.Field(f => f.Content)
)
.Remove<Attachment>(r => r
.Field(f => f.Content)
)
)
)
)
);
//var t = await _client.GetPipelineAsync(ts => ts.Id("*"));
var request = new IndexRequest<ApplicationDto>(indexName, "applicationdto", applicationId)
{
Pipeline = "attachments",
Document = application
};
var result = await _client.IndexAsync(request);
}
What changes can be done to the code above, so it processes within an array of attachments.