用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. ovs加dpdk在日志中查看更多运行细节的方法

    想查看更多dpdk+ovs的更多运行细节,可以采用以下方法,增加更多运行日志. 在终端输入: ovs-appctl vlog/set dpdk:file:dbg ovs-appctl vlog/set ...

  2. webpack+vuecli使用问题总结

    1,按照官网安装步骤install $ npm install -g vue-cli $ vue init webpack my-project $ cd my-project $ npm insta ...

  3. Java基础之File类的使用

    Java基础之File类的使用 1.File类的构造方法和常用方法 2.对File中listFile(FileNameFilter name)学习 3.与File文件类相关的实现 File类的构造方法 ...

  4. BootStrapValidate 简单使用

    前阵子用了bootstrapvalidate写了一个登录验证,这里小记一笔 首先需要引入 bootstrapValidator.css //可不引入 jquery-2.1.0.min.js boots ...

  5. Elasticsearch 6.3.1、Head插件 安装及配置

    安装Elasticsearch Elasticsearch下载地址:https://www.elastic.co/cn/downloads/elasticsearch 也可以直接使用wget下载到某目 ...

  6. C++11 initializer_list 和 Range-based for loop 学习理解

    win10 + vs2017 源码如下: int main() { vector< int > numbers = { 1, 2, 3, 4, 5 }; for (auto num : n ...

  7. Delphi判断某个类是否实现了某个接口

    通过TObject.GetInterface可以获得对象的实例实现某个接口,前提条件是必须实例化对象后才能运行GetInterface 下面的方法可获取类是否实现了某个接口,并返回接口的偏移: fun ...

  8. Zeta--S3 Linux抓取一帧YUV图像后使用硬件编码器编码成H.264

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h&g ...

  9. 在全志V3/V3s和索智S3/S3L上调试32MB NorFlash

    选取MX25L25635F作为调试对象,其他型号的NorFlash开发调试原理基本一致.为了使V3/V3s/S3/S3L识别32MB NorFlash并正常工作,主要针对以下三个部分进行开发和调试.下 ...

  10. MAC下绕开百度网盘限速下载的方法,三步操作永久生效

    第一步:下载所需工具:(①②步我放在同一个文件夹,可一起下载,链接失效请留言) 工具地址:链接: https://pan.baidu.com/s/1raicYzM 密码: ve3n ①下载Aria2G ...