{"expected:'[', actual:'{', at offset:2058"}

Hi,
I'm new to elastic and FSCrawler.
I have an index created using FSCrawler. It has only a single document which looks like below -

 {
          "content" : """MotorColour - 
		

CoatingColor - 	
		


CSV

	
""",
          "meta" : { },
          "file" : {
            "extension" : "txt",
            "content_type" : "text/plain; charset=windows-1252",
            "created" : "2022-06-20T05:56:52.641+00:00",
            "last_modified" : "2022-03-05T05:25:55.594+00:00",
            "last_accessed" : "2022-06-23T08:19:48.828+00:00",
            "indexing_date" : "2022-06-23T09:09:28.997+00:00",
            "filesize" : 239,
            "filename" : "1.txt",
            "url" : """file://C:\temp\tmp\es\1.txt"""
          },
          "path" : {
            "root" : "fda731c3ec0bf30ff36fecce8c4155e",
            "virtual" : """\1.txt""",
            "real" : """C:\temp\tmp\es\1.txt"""
          }
        }

When i issue this Query using NEST client library

searchResponse = client.Search<DesignFile>(s => s
             .Index(FileIndexName)
             .Query(q => q
                .MatchAll()
              )
             );

it gives an error

Elasticsearch.Net.Utf8Json.JsonParsingException: expected:'[', actual:'{', at offset:2058
   at Elasticsearch.Net.Utf8Json.JsonReader.ReadIsBeginArrayWithVerify()
   at Elasticsearch.Net.Utf8Json.Formatters.ArrayFormatter`1.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Deserialize(Object[] , JsonReader& , IJsonFormatterResolver )
   at Elasticsearch.Net.Utf8Json.Resolvers.DynamicMethodAnonymousFormatter`1.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Deserialize(Object[] , JsonReader& , IJsonFormatterResolver )
   at Elasticsearch.Net.Utf8Json.Resolvers.DynamicMethodAnonymousFormatter`1.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Nest.SourceFormatter`1.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Deserialize(Object[] , JsonReader& , IJsonFormatterResolver )
   at Elasticsearch.Net.Utf8Json.Resolvers.DynamicMethodAnonymousFormatter`1.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Nest.ReadAsFormatter`2.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Elasticsearch.Net.Utf8Json.Formatters.CollectionFormatterBase`4.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Deserialize(Object[] , JsonReader& , IJsonFormatterResolver )
   at Elasticsearch.Net.Utf8Json.Resolvers.DynamicMethodAnonymousFormatter`1.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Nest.ReadAsFormatter`2.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Deserialize(Object[] , JsonReader& , IJsonFormatterResolver )
   at Elasticsearch.Net.Utf8Json.Resolvers.DynamicMethodAnonymousFormatter`1.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Elasticsearch.Net.Utf8Json.JsonSerializer.Deserialize[T](Byte[] bytes, Int32 offset, IJsonFormatterResolver resolver)
   at Elasticsearch.Net.Utf8Json.JsonSerializer.Deserialize[T](Stream stream, IJsonFormatterResolver resolver)
   at Nest.DefaultHighLevelSerializer.Deserialize[T](Stream stream)
   at Elasticsearch.Net.DiagnosticsSerializerProxy.Deserialize[T](Stream stream)
   at Elasticsearch.Net.ResponseBuilder.SetBody[TResponse](ApiCallDetails details, RequestData requestData, Stream responseStream, String mimeType)
   at Elasticsearch.Net.ResponseBuilder.ToResponse[TResponse](RequestData requestData, Exception ex, Nullable`1 statusCode, IEnumerable`1 warnings, Stream responseStream, String productName, String mimeType)
   at Elasticsearch.Net.HttpConnection.Request[TResponse](RequestData requestData)
   at Elasticsearch.Net.RequestPipeline.CallElasticsearch[TResponse](RequestData requestData)

i think it has something to do with the serialization?
What is the way to get rid of the error and be able to search the index?

Here is the content of the text file that i indexed using FSCrawler -

MotorColour - 
		

CoatingColor - 	
		


CSV - 

Hi, @Zedson.Sagar,

This appears to be a deserialisation issue of the source to your DesignFile type. It looks like the serialisation is expecting to deserialise a collection for one of the properties, but the JSON includes an object. Can you please share the DesignFile class definition?

@stevejgordon
aaah.. how did i miss that !!!... i had mistakely set one of the properties as an array of objects instead of an object. Thanks for the pointer.. foolish me wasted 3hrs for this :rofl:

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