繁体   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