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.

  • 相关阅读:
    lambda函数用法
    Appium基础篇-元素定位
    python生成测试报告
    jmeter 设置中文
    jmeter bin下常用目录
    高效求幂运算
    欧几里德算法(求最大公因数)
    二分查找
    最大子序列和问题
    秋游小记
  • 原文地址:https://www.cnblogs.com/iDream2018/p/12371911.html
Copyright © 2011-2022 走看看