How do I save array of bytes as actual array in NEST

I have a simple POCO object with following definition

public class MyClass 
{
   public byte[] Assortment {get;set;}
}

And I want to save it as [1,2,3] in elasticsearch. But when I simply create an object of that type and insert it into index I just get binary encoded value like AQMoAgkEBwUILy0uJicG. Sample code:

var settings = new ConnectionSettings(new Uri(elasticSettings.NodeUri)).DefaultIndex(elasticSettings.Index);
var elasticClient = new ElasticClient(settings);
MyClass[] requests = { new MyClass {Assortment = new byte[] {1,3,40,2,9,4,7,5,8,47,45,46,38,39,6} }};
var bulkResponse = await elasticClient.IndexManyAsync(requests, cancellationToken: cancellationToken);

If I manually create an index and set array type I get following errors when saving:

System.AggregateException: One or more errors occurred. (Error while processing bulk request: Invalid NEST response built from a successful low level call on POST: /_bulk
# Invalid Bulk items:
  operation[0]: index returned 400 _index: blockchain _type: elasticrequest _id: eqa04WUByNd1edqilegT _version: 0 error: Type: mapper_parsing_exception Reason: "failed to parse [assortment]" CausedBy:
Type: illegal_argument_exception Reason: "For input string: "AQMoAgkEBwUILy0uJicG""
  operation[1]: index returned 400 _index: blockchain _type: elasticrequest _id: e6a04WUByNd1edqilegT _version: 0 error: Type: mapper_parsing_exception Reason: "failed to parse [assortment]" CausedBy:
Type: illegal_argument_exception Reason: "For input string: "AQMoAgkEBwUILy0uJicG""
  operation[2]: index returned 400 _index: blockchain _type: elasticrequest _id: fKa04WUByNd1edqilegT _version: 0 error: Type: mapper_parsing_exception Reason: "failed to parse [assortment]" CausedBy:
Type: illegal_argument_exception Reason: "For input string: "AQMoAgkEBwUILy0uJicG""

I don't want to binary encode the value, I just want to create an array of values.

I tried Text/Number/Object attributes, but they don't work.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.