根据入门文档,我正在使用nest asp对弹性搜索执行简单的聚合查询。但是我收到错误{Invalid NEST response built from a unsuccessful low level call on POST: /people/_search?typed_keys=true}
。我正在使用Nest 7.0.0。与Elasticsearch Cloud Service一起使用的是Elasticsearch 7.0.0。下面的代码说明了我如何设置elasticclient以及如何执行查询。
我使用相同的连接来执行成功的查询操作,因此我认为我的连接没问题,索引设置也没问题。
var settings = new ConnectionSettings("my_elasticsearch_url").DefaultIndex("people");
ElasticClient elasticClient = new ElasticClient(settings);
Person person = new Person()
{
FirstName = "George",
LastName = "Ouma"
};
var indexResponse = elasticClient.IndexDocument(person);
var searchResponse = elasticClient.SearchAsync<Person>(s =>
s.Size(0)
.Query(q => q
.Match(m=>m
.Field(f=>f.FirstName)
.Query("George")
)
)
.Aggregations(a => a
.Terms("first_names", ta => ta
.Field(f => f.FirstName)
)
)
).GetAwaiter().GetResult();
var aggregations = searchResponse.Aggregations.Terms("first_names");
我希望获得合计结果,但是得到null
并检查searchResponse
对象时,我得到了错误消息{Invalid NEST response built from a unsuccessful low level call on POST: /people/_search?typed_keys=true}
答案 0 :(得分:0)
所有积分都归@Rob所有,解决此问题的方法是将后缀keyword
添加到字段中,如下所示:.Field(f => f.FirstName.Suffix("keyword"))