Elasticsearch.Net 异常:[match] query doesn't support multiple fields, found [field] and [query]
用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]的更多相关文章
- ES query does not support [auto_generate_synonyms_phrase_query]
测试环境使用 elasticsearch-rest-high-level-client 做为基础包发起es调用出现如下异常: {"error":{"root_caus ...
- elasticsearch 查询(match和term)
elasticsearch 查询(match和term) es中的查询请求有两种方式,一种是简易版的查询,另外一种是使用JSON完整的请求体,叫做结构化查询(DSL). 由于DSL查询更为直观也更为简 ...
- (转载)elasticsearch 查询(match和term)
原文地址:https://www.cnblogs.com/yjf512/p/4897294.html elasticsearch 查询(match和term) es中的查询请求有两种方式,一种是简易版 ...
- SpringBoot启动使用elasticsearch启动异常:Received message from unsupported version:[2.0.0] minimal compatible
SpringBoot启动使用elasticsearch启动异常:Received message from unsupported version:[2.0.0] minimal compatible ...
- 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 ...
- 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 ...
- 使用elasticsearch启动项目报错failed to load elasticsearch nodes 。。。。。No type specified for field [name]
failed to load elasticsearch nodes .....No type specified for field [name]翻译: 加载ElasticSearch节点失败... ...
- 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 ...
- Elasticsearch搜索异常-------org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: parse_exception
异常问题: Caused by: org.elasticsearch.index.query.QueryShardException: Failed to parse query [LOL: Uzi和 ...
随机推荐
- ztz11的noip模拟赛T1:愤怒的XiaoX
链接: https://www.luogu.org/problemnew/show/U47231 思路: 这道题其实就是一道双Lazy线段树裸题 因为我们知道,当k一定时,取反偶数次最后k位等于不取反 ...
- No space left on device 解决 Cydia 安装应用错误
在 Cydia 上搜索应用进行安装,提示错误:failed to write (No space left on device),从字面上的意思看是磁盘空间不够,导致写入错误,但是到 “关于” 里看到 ...
- Flume(5)-Ganglia监控
一. 安装Ganglia 1. 安装httpd服务与php sudo yum -y install httpd php 2. 安装其他依赖 sudo yum -y install rrdtool pe ...
- 盒模型與BFC
盒模型 基本概念 什么是 CSS 盒模型?相信大部分人都能答出这个问题来,那就是 标准模型 + IE 模型 标准模型: IE 模型 很明显 在 标准盒子模型中,width 和 height 指的是内容 ...
- 中国大学MOOC-JAVA学习(浙大翁恺)—— 时间换算
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto- ...
- 理解 ajax、fetch和axios
背景 ajax fetch.axios 优缺点 ajax基于jquery,引入时需要引入庞大的jquery库,不符合当下前端框架,于是fetch替代了ajax 由于fetch是比较底层,需要我们再次封 ...
- Parallel Pattern Library(PPL)学习笔记
关于PPL是什么,可以搜索关键字MSDN PPL了解详情.这里谈一下困扰自己好一阵子的一个地方--task chain中抛出异常的处理,一来可为其他码农同行参考,二来给自己做个记录,以免日后忘却. V ...
- 探秘GO语言《比较C#与GO的性能--XML序列化》
今天对GO和NET的XML字符串序列化成对象列表做了一个性能比较,得出一些结论. GO的代码: package main import ( "encoding/xml" " ...
- 10 Quality Free Flat Icon Sets for Your Designs
Subscribe It’s clear that flat design has gained great popularity in recent years. This is hardly su ...
- 20155210潘滢昊 Java第二次试验
20155210潘滢昊 Java第二次试验 实验内容 学会JunitTest的使用 实验代码 MyUtilTest代码: import org.junit.*; import junit.framew ...