gpt4 book ai didi

elasticsearch - 将Elasticsearch查询转换为.net NEST

转载 作者:行者123 更新时间:2023-12-03 00:03:16 25 4
gpt4 key购买 nike

如何将这个Elasticsearch匹配查询写入C#.net NEST。

 GET /disney2/character/_search
{
"query": {
"match": {
"name.phonetic": {
"query": "Jahnnie Smeeth",
"operator": "and"
}
}
}
}

最佳答案

使用对象初始化器的语法:

        ConnectionSettings _clientSettings = new ConnectionSettings(new Uri("http://localhost:9200/disney2"));
var client = new ElasticClient(_clientSettings);
var query = new SearchRequest<disney>(); // You're going to want to replace <object> with a model corresponding to your type, or specify the type via string
var matcher = new MatchQuery();
matcher.Field = "name.phonetic";
matcher.Query = "Jahnnie Smith";
matcher.Operator = Operator.And;
query.Query = matcher;

//var res = elasticClient.Search<disney>(query);
var res = client.Search<disney>(query);

关于elasticsearch - 将Elasticsearch查询转换为.net NEST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46958983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com