1、使用DoRequest/DoRequestAsync发送请求
var lowLevelClient = new ElasticLowLevelClient();
var stringResponse = lowLevelClient.DoRequest<StringResponse>(
HttpMethod.POST,
"_search",
PostData.Serializable(new
{
query = new { match_all = new { } }
}));
2、通过.LowLevel调用DoRequest()发送请求
var client = new ElasticClient();
var stringResponse = client.LowLevel.DoRequest<StringResponse>(
HttpMethod.POST,
"_search",
PostData.Serializable(new
{
query = new { match_all = new { } }
}));
3、使用请求内的匿名类型弹性搜索(Search)查询DSL
var lowlevelClient = new ElasticLowLevelClient();
var searchResponse = lowlevelClient.Search<string>("people", "person", new
{
from = 0,
size = 10,
query = new
{
match = new
{
field = "firstName",
query = "Martijn"
}
}
});
var successful = searchResponse.Success;
var responseJson = searchResponse.Body;