用Elasticsearch.Net检索数据,报异常:

var settings = new ConnectionConfiguration(new Uri("http://localhost:9200")).RequestTimeout(TimeSpan.FromMinutes());

ElasticLowLevelClient client = new ElasticLowLevelClient(settings);

var searchResponse = client.Search<StringResponse>("test", "Person", PostData.Serializable(new
{
from = ,
size = ,
query = new { match = new { field = "name", query = "chenzongyan" }}
})); string body = searchResponse.Body;
Console.WriteLine(body);
Console.ReadKey();

异常信息:

{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[match] query doesn't support multiple fields, found [field] and [query]",
"line": ,
"col":
}
],
"type": "parsing_exception",
"reason": "[match] query doesn't support multiple fields, found [field] and [query]",
"line": ,
"col":
},
"status":
}

解决办法:

var searchResponse = client.Search<StringResponse>("test", "Person", PostData.Serializable(new
{
from = 0,
size = 10,
query = new
{
multi_match = new
{
fields = "name",
query = "chenzongyan"
}
}
}));

 将match 改为 multi_match ,field改为fields.

检索结果:

{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.2876821,
"hits": [
{
"_index": "test",
"_type": "Person",
"_id": "WOgCs2UBfhVuaFPoccea",
"_score": 0.2876821,
"_source": {
"name": "chenzongyan",
"Age": 27
}
}
]
}
}

参考:https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/elasticsearch-net-getting-started.html

Elasticsearch.Net 异常:[match] query doesn't support multiple fields, found [field] and [query]的更多相关文章

  1. ES query does not support [auto_generate_synonyms_phrase_query]

    测试环境使用  elasticsearch-rest-high-level-client  做为基础包发起es调用出现如下异常: {"error":{"root_caus ...

  2. elasticsearch 查询(match和term)

    elasticsearch 查询(match和term) es中的查询请求有两种方式,一种是简易版的查询,另外一种是使用JSON完整的请求体,叫做结构化查询(DSL). 由于DSL查询更为直观也更为简 ...

  3. (转载)elasticsearch 查询(match和term)

    原文地址:https://www.cnblogs.com/yjf512/p/4897294.html elasticsearch 查询(match和term) es中的查询请求有两种方式,一种是简易版 ...

  4. SpringBoot启动使用elasticsearch启动异常:Received message from unsupported version:[2.0.0] minimal compatible

    SpringBoot启动使用elasticsearch启动异常:Received message from unsupported version:[2.0.0] minimal compatible ...

  5. MongoDB - MongoDB CRUD Operations, Query Documents, Project Fields to Return from Query

    By default, queries in MongoDB return all fields in matching documents. To limit the amount of data ...

  6. MongoDB - MongoDB CRUD Operations, Query Documents, Query for Null or Missing Fields

    Different query operators in MongoDB treat null values differently. The examples on this page use th ...

  7. 使用elasticsearch启动项目报错failed to load elasticsearch nodes 。。。。。No type specified for field [name]

    failed to load elasticsearch nodes .....No type specified for field [name]翻译: 加载ElasticSearch节点失败... ...

  8. Elasticsearch 报错:Fielddata is disabled on text fields by default. Set `fielddata=true` on [`your_field_name`] in order to load fielddata in memory by uninverting the inverted index.

    Elasticsearch 报错: Fielddata is disabled on text fields by default. Set `fielddata=true` on [`your_fi ...

  9. Elasticsearch搜索异常-------org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: parse_exception

    异常问题: Caused by: org.elasticsearch.index.query.QueryShardException: Failed to parse query [LOL: Uzi和 ...

随机推荐

  1. C语言的谜题

    本篇文章<C语言的谜题>展示了14个C语言的迷题以及答案,代码应该是足够清楚的,而且我也相信有相当的一些例子可能是我们日常工作可能会见得到的.通过这些迷题,希望你能更了解C语言.如果你不看 ...

  2. Nested Loops,Hash Join 和 Sort Merge Join. 三种不同连接的不同:

    原文:https://blog.csdn.net/tianlesoftware/article/details/5826546 Nested Loops,Hash Join 和 Sort Merge ...

  3. OO 第三次博客总结

    调研规格化设计 1950年代,第一次分离,主程序和子程序的分离程序结构模型是树状模型,子程序可先于主程序编写.通过使用库函数来简化编程,实现最初的代码重用.产生基本的软件开发过程:分析—设计—编码—测 ...

  4. ZJOI2008]树的统计(树链剖分,线段树)

    题目描述 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w. 我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. QMAX u ...

  5. code#5 P4 逻辑树

    逻辑树   时间限制: 3.0 秒 空间限制: 512 MB 相关文件: 题目目录 题目描述 有一棵树,叫逻辑树. 这个树有根,有 2N−1 个节点,其中 N 个叶子,每个非叶节点恰好有两个孩子. 每 ...

  6. 课时26.a标签其它属性(掌握)

    4.a标签的href属性除了可以指定一个网络地址以外,还可以指定一个本地地址 a标签中还有一个属性,叫做title,a标签中的title和img标签中的title一样,都是用来控制鼠标悬停时显示的提示 ...

  7. keil编译运行错误,缺少error:#5:#include "core_cm3.h"

    用Keil  vision5编译时出现以下错误:error:  #5: cannot open source input file "core_cm3.h": No such fi ...

  8. Python图形界面Tk

    最近在学习Python,在使用Tkinter做图形界面时遇到了几个小问题,网上查了一下,在Python2.x导入的是Tkinter,Python3则是tkinter.而且导入的simpledialog ...

  9. node从搭建运行项目整体流程

    1. 初始化配置基本信息: npm init (自定义配置) npm init -y (一切配置采用默认值) 在当前目录产生package.json文件,有一个dependencies用来记录该项目所 ...

  10. Angular5学习笔记 路由配置

    因为angular-cli脚手架的关系,所以配置路由可以通过命令行来创建路由文件 原本创建一个angular项目的命令是ng new 项目名,就可以了,但这样创建出来的项目是没有路由文件的. 如果需要 ...