用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. Android自定义控件——有弹性的ListView,ScrollView

    上一次我们试验了有弹性的ScrollView.详情 这一次,我们来试验有弹性的ScrollView. 国际惯例,效果图: 主要代码: [java] view plaincopy import andr ...

  2. 【算法学习】AVL平衡二叉搜索树原理及各项操作编程实现(C语言)

    #include<stdio.h> #include "fatal.h" struct AvlNode; typedef struct AvlNode *Positio ...

  3. 不会发布npm包?进来看看?

    前言 npm(Node Package Manager),一个Node的包管理器,平时我们常用的公共模块(插件)或者叫做包大多都放在上面,所以接下来要封装的插件,我们就简单称它为npm包,本文从就从这 ...

  4. MySQL的笔记

    一.   SELECT tmp2.name,tmp2.browseNum FROM (SELECT tmp.`name`, COUNT(tmp.id) AS browseNum FROM(SELECT ...

  5. File、Paths和Files类的使用详解

    Paths:通过get()方法返回一个Path对象,Path用于表示文件路径和文件. Files:提供了大量处理文件的方法,例如文件复制.读取.写入,获取文件属性.快捷遍历文件目录等..... Fil ...

  6. T-SQL查询:WITH AS 递归计算某部门的所有上级机构或下级机构

    drop table #Area; CREATE TABLE #Area ( id INT NOT NULL, city_name NVARCHAR(100) NOT NULL, parent_id ...

  7. 实现 在子界面的button按下,在主界面的label显示。

    不知道理解的对不对,反正功能是实现了. 这是子界面,COM口配置界面的 .H文件的定义.下面的Private:定义了Ui:MainWindow  *main_ui;的指针变量      要   注  ...

  8. LL(1)文法--递归下降程序

    递归下降程序 递归下降程序一般是针对某一个文法的.而递归下降的预测分析是为每一个非终结符号写一个分析过程,由于文法本身是递归的,所以这些过程也是递归的. 以上是前提. Sample 假如给的是正规式子 ...

  9. 【ZOJ 2996】(1+x)^n(二项式定理)

    Please calculate the coefficient modulo 2 of x^i in (1+x)^n. Input For each case, there are two inte ...

  10. mysql-8.0.15允许外网访问

    1.进MySQL之后, 2.输入以下语句,进入mysql库: use mysql3.更新域属性,'%'表示允许外部访问: update user set host='%' where user ='r ...