Elasticsearch.Net.UnexpectedElasticsearchClientException: during getting data from ES

0

I have a c# project which i want send a request to my elastic search server. this is my connection and elastic search client :

var nodes = new Uri[]
            {
             new Uri("http://localhost:9200"),
            };

            connectionPool = new StaticConnectionPool(nodes);
            settings = new ConnectionSettings(connectionPool);
            settings.DefaultIndex("restaurants");
            client = new ElasticClient(settings);

this is my model :

class restaurants
    {
        public string name { get; set; }
        public GeoCoordinate location { get; set; }
    }

and this is the request:(in all sorts of variations)

 var searchResponse = client.Search<restaurants>(s => s.Query(q => q.Match(m => m.Field(f => f.name == "Cafe Cafe"))));

but when I send request, I get this exception :

Elasticsearch.Net.UnexpectedElasticsearchClientException
  HResult=0x80131500
  Message=Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Int64' because the type requires a JSON primitive value (e.g. string, number, boolean, null) to deserialize correctly.
To fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'hits.total.value', line 1, position 113.
  Source=Elasticsearch.Net

Can someone help, what's wrong with it?

EDIT: Here is my data (from search in Kibana):

{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "restaurants",
        "_type" : "restaurant",
        "_id" : "6",
        "_score" : 1.0,
        "_source" : {
          "name" : "Cafe Cafe",
          "location" : "41.12,-71.34"
        }
      }
    ]
  }
}
c#
elasticsearch
nest
asked on Stack Overflow May 14, 2019 by champion... • edited May 14, 2019 by champion...

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0