如何增加要在 C# 中显示在 ElasticaSearch 中的记录

How To increase the records to be shown in ElasticaSearch in c#

默认显示 10000,我想显示更多

这是尝试过的

这是这个的方法

public JsonResult GetUsageLog()
        {
            List<AcctountSession> data = new List<AcctountSession>();
            ISearchResponse<AcctountSession> responsedata = null;
            var query = new object();
    
            try
            {
                var defaultIndex = "all-radius-session-*";

                var settings = new ConnectionSettings(new Uri(allElasticUrl)).DefaultIndex("acctountsessionid");
                ElasticClient Elastic = new ElasticClient(settings);


                var sqlResponse = Elastic.Sql.Query(q => q.Query("SELECT count(0) from all-radius-session-* WHERE timestamp>='2022-03-01T00:00:00' and timestamp='2022-04-01T00:00:00'"));

            
                if (Elastic.Indices.Exists(defaultIndex).Exists)
                {
                    responsedata = Elastic.Search<AcctountSession>(s => s
                               .Index(defaultIndex)
                               .Size(10000)
                               .TrackTotalHits(true)
                               .Query(q => q.DateRange(r => r
                               .Field(p => p.Timestamp)))
                               .Sort(p => p.Descending("@timestamp")));
                    data = (from hits in responsedata.Hits select hits.Source).ToList();

                    query = data.GroupBy(x => new { x.Timestamp.Date, x.cust_id, x.snl_dev_id, x.ftc_code, x.service_type })
                                .Select(group => new
                                {
                                    date = Convert.ToDateTime(group.Key.Date).ToString("dd-MM-yyyy"),
                                    cust_id = group.Key.cust_id,
                                    snl_dev_id = group.Key.snl_dev_id,
                                    ftc_code= group.Key.ftc_code,
                                    service_type = group.Key.service_type,
                                    acctountinputoctets = group.Sum(x => x.acctountinputoctets ),
                                    acctountoutputoctets = group.Sum(x => x.acctountoutputoctets ),
                                    acctipv6inputoctets = group.Sum(x => ((x.acctipv6inputoctets != null && x.acctipv6inputoctets != "") ? Int64.Parse(x.acctipv6inputoctets) : Int64.Parse("0"))),
                                    acctipv6outputoctets = group.Sum(x => ((x.acctipv6outputoctets != null && x.acctipv6inputoctets != "") ? Int64.Parse(x.acctipv6outputoctets) : Int64.Parse("0")))
                                });

                }
            }
            catch (Exception ex)
            {

            }
            var jsonResult = Json(query, JsonRequestBehavior.AllowGet);
            jsonResult.MaxJsonLength = int.MaxValue;
            return jsonResult;
        }

如果假设我有超过 10K logs/results 的最新版本的 Elasticsearch

,我该如何获取所有日志

在此我如何尝试修改它以提供超过 10000

我可以为此尝试什么

您可以使用 Scrolling API 的 Elasticsearch 从索引中检索超过 10k 的文档。

下面是一个简单的例子:

var searchResponse = Client.Search<Project>(s => s
    .Query(q => q
        .Term(f => f.State, StateOfBeing.Stable)
    )
    .Scroll("10s") 
);

while (searchResponse.Documents.Any()) 
{
    ProcessResponse(searchResponse); 
    searchResponse = Client.Scroll<Project>("10s", searchResponse.ScrollId);
}