Nest Elasticsearch match_phrase 查询抛出解析异常
Nest Elasticsearch match_phrase query throws parsing exception
我正在使用 Nest elasticSearch 作为客户端库来与 elasticSearch 索引进行交互。
我正在尝试使用以下代码发送 match_phrase 查询:
var searchResponse = elasticClient.Search<ProductType>(s => s
.Index(indices)
.Type(Types.Type(typeof(ProductType)))
.From(0)
.Size(5)
.Query(q =>
q.MatchPhrase(m => m
.Field(Infer.Field<ProductType>(ff => ff.Title))
.Slop(5)
.Query("my query")
)
)
);
它正在生成以下查询:
GET /product/_search
{
"from": 0,
"size": 5,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"match": {
"title": {
"type": "phrase",
"query": "my query",
"slop": 5
}
}
}
}
当我执行上面的查询时 returns parsing_exception:
[match] query does not support [type]
我期望上面的代码 return 查询如下:
GET /product/_search
{
"from": 0,
"size": 5,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"match_phrase": {
"title": {
"query": "my query",
"slop": 5
}
}
}
}
那么我的代码有什么问题吗?我该如何摆脱它?
经过调查并根据 match query does not support type,我发现我在升级 ElasticSearch 上托管集群的服务器升级到 V6.5.0,事实证明我应该升级我的 Nest NuGet 包,现在它正在生成 match_phrase 按预期查询。
我正在使用 Nest elasticSearch 作为客户端库来与 elasticSearch 索引进行交互。
我正在尝试使用以下代码发送 match_phrase 查询:
var searchResponse = elasticClient.Search<ProductType>(s => s
.Index(indices)
.Type(Types.Type(typeof(ProductType)))
.From(0)
.Size(5)
.Query(q =>
q.MatchPhrase(m => m
.Field(Infer.Field<ProductType>(ff => ff.Title))
.Slop(5)
.Query("my query")
)
)
);
它正在生成以下查询:
GET /product/_search
{
"from": 0,
"size": 5,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"match": {
"title": {
"type": "phrase",
"query": "my query",
"slop": 5
}
}
}
}
当我执行上面的查询时 returns parsing_exception:
[match] query does not support [type]
我期望上面的代码 return 查询如下:
GET /product/_search
{
"from": 0,
"size": 5,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"match_phrase": {
"title": {
"query": "my query",
"slop": 5
}
}
}
}
那么我的代码有什么问题吗?我该如何摆脱它?
经过调查并根据 match query does not support type,我发现我在升级 ElasticSearch 上托管集群的服务器升级到 V6.5.0,事实证明我应该升级我的 Nest NuGet 包,现在它正在生成 match_phrase 按预期查询。