zoukankan      html  css  js  c++  java
  • Elasticsearch.Net

    今天使用Elasticsearch作开发,很简单的查询,就出现Elasticsearch.Net.UnexpectedElasticsearchClientException异常,看样子像是序列化的异常,但实则是Elasticsearch服务器版本和C#用的Elasticsearch.Net客户端版本不匹配导致!

    感谢某位仁兄在这篇博客https://www.cnblogs.com/yswenli/p/6266569.html#4387519中答复某位网友遇到同样的问题

    var searchResponse = client.Search<LogModel>(s => s
                .Query(q => q
                .Match(m => m
                .Field(f => f.D)
                .Query(“Hello world”))));

    Elasticsearch.Net.UnexpectedElasticsearchClientException:“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.”

    内部异常:

    JsonSerializationException: 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.

  • 相关阅读:
    LVS负载均衡NAT模式实现
    Linux-ftp服务搭建
    Keepalived配置详解
    Keepalived高可用概念篇
    Nginx-http_proxy_module模块
    Nginx-keepalived+Nginx实现高可用集群
    Oracle注入之带外通信
    Oracle基于延时的盲注总结
    Oracle基于布尔的盲注总结
    Oracle报错注入总结
  • 原文地址:https://www.cnblogs.com/iDream2018/p/12371911.html
Copyright © 2011-2022 走看看