我想使用c#Nest客户端搜索和过滤数据 下面是使用Javascript-Elastic搜索和类似客户端编写的查询我试图用c#编写,但它没有按预期工作
Javascript弹性搜索客户端:
var from_ms = from.getTime();
var to_ms = to.getTime();
var query = 'temp:' + Temp + ' AND url:"type=' + value + '"';
client.search({
type: 'Type',
size: 5000,
q: query,
body: {
sort: [
{
"@timestamp": {
"order": "desc"
}
}
],
filter: {
"range": {
"@timestamp": {
"from": from_ms,
"to": to_ms
}
}
//"range": { "@timestamp": { "from": 1444118389, "to": 1444120189 }}
}
}
}).
C#弹性搜索代码我试过但它没有按预期工作 我没有得到如何在c#中添加查询,就像我在JS中一样,以及如何使用时间戳过滤数据
class ElasticearchQuery
{
public class REstt
{
public string test{ get; set; }
public string url { get; set; }
}
static void Main(string[] args)
{
try
{
var connection = new X509CertificateHttpConnection();
var connectionPool = new SingleNodeConnectionPool(new Uri("https://www.yy.com"));
var settings = new ConnectionSettings(connectionPool, connection);
var client = new ElasticClient(settings);
REstt person = new REstt();
QueryContainer query = new TermQuery()
{
Field = "temp",
Value = "value"
};
var searchRequest = new SearchRequest
{
From = 0,
Size = 5000,
Query = query
};
var searchResults = client.Search<REstt>(searchRequest);
var temp = searchResults.Hits;
Console.WriteLine(temp);
}
catch (Exception e)
{
}
}
}