簡體   English   中英

彈性搜索所有匹配文檔的總計數值

[英]Elastic Search Query for Total Count value for all the matching documents

我是ElasticSearch .NET集成的新手。 我正在搜索索引數據(其中我已索引10000條以上的記錄,但是當我進行搜索時,即使所有10000條記錄都應出現,因為所有記錄均以搜索到的值開頭,但我最多只能獲取250條記錄

請找到我寫的查詢:

string UniqueID ='h';
var result = client.Search<MemberListDto>(s => s
                   .Query(q =>
                               q.MatchPhrasePrefix((mq => mq.Field(f => f.UniqueID).Query(UniqueID)))
                       ));

            return result.Total;

注意:所有的UniqueID值都以'h'開頭,而我僅給出UniqueID ='h'。

請幫助我,如果滿足查詢條件值,我如何獲得所有10000條記錄。

這是我要索引的POCO C#類對象:

public class MemberListDto
{

    [String(Analyzer = "keyword", SearchAnalyzer = "keyword")]
    public string UniqueID { get; set; }
    [String(Analyzer ="keyword",SearchAnalyzer ="keyword")]
    public string Name{ get; set; }

}

這是我正在嘗試對MemberListDto對象列表進行批量索引的通用代碼:

public void CreateBulkIndex<T>(List<T> data, string indexName, string typeName) where T : class
    {

        if (!_client.IndexExists(ElasticConfig.IndexName).Exists)
        {
            var indexDescriptor = new CreateIndexDescriptor(ElasticConfig.IndexName)
                .Mappings(ms => ms
                    .Map<T>(m => m.AutoMap()));

            _client.CreateIndex(ElasticConfig.IndexName, i => indexDescriptor);
        }
        _client.Bulk(b => b.IndexMany(data, (d, doc) => d.Document(doc).Index(indexName)));

    }

嘗試通過調用Size設置Size 您將獲得默認的響應文檔數。 在Elastic上參考此內容 ,了解如何設置尺寸

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM