用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. LCG(linear congruential generator): 一种简单的随机数生成算法

    目录 LCG算法 python 实现 LCG算法 LCG(linear congruential generator)线性同余算法,是一个古老的产生随机数的算法.由以下参数组成: 参数 m a c X ...

  2. 用画布canvas画安卓logo

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. C# 缓存工厂类

    描 述:缓存工厂类 /// <summary> /// 描 述:缓存工厂类 /// </summary> public class CacheFactory { /// < ...

  4. ORA-28002 密码过期解决方案

    ORA-28002 密码过期解决方案 错误场景:当使用sqlplus进行登录时报错:ORA-28002 密码过期.错误原因:由于oracle 11g 在默认在default概要文件中设置了密码过期天数 ...

  5. MyEclipse部署项目时点finish点不动finish按钮灰色的

    在MyEclipse中项目的propertes中输入tomcat搜索,jdk选择你本机安装的jdk

  6. python从Excel中提取邮箱

    从各个城市的律师协会去爬取的律师的招聘信息,可是邮箱在招聘简介里面,所有需要写个脚本去提取邮箱 import pandas as pd import re regex = r"([-_a-z ...

  7. ubuntu apt源配置

    前言:看见Ubuntu新出了18.04版本感觉不错,装一个玩玩,虽然有很多教程可以参考,但我也给出一个不是很一样的方案吧,尽量解释的详细一点. 为了下载更方便,速度更快,我们往往在使用Linux系列系 ...

  8. ubuntu18.04 VirtualBox 开启虚拟机出错 Kernel driver not installed (rc=-1908)

    写的很明白了 提示缺少GCC PERL MAKE,安装 重试..... 重启VM 搞定....

  9. 虚拟机安装与Linux命令的学习 ——20155215宣言

    一.虚拟机的安装 虚拟机的安装对我来说真可谓是一波三折.打开老师发布的安装教程,简单地浏览了一下,主要步骤都有图文解说.我本来以为这个安装按部就班即可,可哪知道,问题一个接着一个出现. 问题1 在我下 ...

  10. 第六周课上测试-3-ch02补充作业

    实验要求: 编写一个程序 "week0603学号.c",运行下面代码: short int v = -学号后四位 unsigned short uv = (unsigned sho ...