using System.Collections.Generic;
public static void Main()
var node = new Uri("https://pageviewtrack.monotype.com");
var settings = new ConnectionSettings(node);
var client = new ElasticClient(settings);
settings.DefaultIndex("custfontid*");
var scanResults = SearchService.SearchByDate(client, DateTime.UtcNow.AddDays(-1).Date, DateTime.UtcNow.Date, page, pageSize);
var searchResponse = new ISearchResponse<PVR>
Total = (int)scanResults.Total,
Results = scanResults.Documents,
ElapsedMilliseconds = (int)scanResults.Took,
TotalPages = (int)Math.Ceiling(scanResults.Total / (double)pageSize)
Console.WriteLine($"Total result: {searchResponse.Total} \n Total pages: {searchResponse.TotalPages}");
Console.WriteLine($"Page: {searchResponse.Page} \n Results: {searchResponse.Results.Count()}");
Console.WriteLine($"ElapsedMilliseconds: {searchResponse.ElapsedMilliseconds}");
foreach (var response in searchResponse.Results)
Console.WriteLine($"CustomerId : {response.CustomerId} FontId : {response.FontId} raw_time: {response.ReportingTime} \t referrer: {response.Refdomain} ");
[Text(Name = "customerId")]
public string CustomerId { get; set; }
[Text(Name = "raw_time")]
public DateTime? RawTime { get; set; }
[Number(NumberType.Long)]
public long PageViewCount { get; set; }
[Text(Name = "refdomain")]
public string Refdomain { get; set; }
public string ApiType { get; set; }
public string FontId { get; set; }
[Text(Name = "url_type")]
public string UrlType { get; set; }
[Text(Name = "filename")]
public string FileName { get; set; }
[Text(Name = "reporting_time")]
public DateTime? ReportingTime { get; set; }
public class ISearchResponse<T>
public int Total { get; set; }
public int Page { get; set; }
public IEnumerable<T> Results { get; set; }
public int ElapsedMilliseconds { get; set; }
public int TotalPages { get; set; }
public class SearchService
public static List<PVR> pageViewTrackingList = new List<PVR>();
public static Nest.ISearchResponse<PVR> SearchByDate(ElasticClient client, DateTime maxDate, DateTime minDate, int page, int pageSize)
var result = client.Search<PVR>(s => s
.Ascending("reporting_time"))
.Field(f => f.ReportingTime)
.GreaterThanOrEquals(maxDate)