У меня есть проект на c #, и я хочу отправить запрос на мой сервер эластичного поиска. это мой клиент для поиска и поиска:
var nodes = new Uri[]
{
new Uri("http://localhost:9200"),
};
connectionPool = new StaticConnectionPool(nodes);
settings = new ConnectionSettings(connectionPool);
settings.DefaultIndex("restaurants");
client = new ElasticClient(settings);
это моя модель:
class restaurants
{
public string name { get; set; }
public GeoCoordinate location { get; set; }
}
и это запрос: (во всех вариациях)
var searchResponse = client.Search<restaurants>(s => s.Query(q => q.Match(m => m.Field(f => f.name == "Cafe Cafe"))));
но когда я отправляю запрос, я получаю это исключение:
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
Может кто-нибудь помочь, что с ним не так?
EDIT:
Вот мои данные (из поиска в Кибане):
{
"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"
}
}
]
}
}