简体   繁体   中英

MultiSearch Query Syntax Using NEST API Elasticsearch

Does anyone know the syntax for using MultiSearch using the NEST library version 7.6.

We have tried:

var result = client.MultiSearch(ms => ms
    .Search<ElasticsearchProject>("projects", s => s.MatchAll())
    .Search<Person>("people", s => s.MatchAll())
);

It seems this is not valid anymore in version 7.6

var d = new MultiSearchDescriptor();
            d.Search<ElasticsearchProject>("projects", s => s
                             .Index("<indexname>")
                               .Query(q => q
                                       .MatchAll()
                                     )
                             .From(1)
                             .Size(10)
                           );
            d.Search<Person>("people", s => s
                           .Index("<indexname>")
                           .Query(q => q
                           .MatchAll()
                               )
                           .From(1)
                           .Size(10)
                         );

            var re = _elasticClient.MultiSearch(d);

MultiSearch expects an Indices as the first parameter, although it is an optional parameter. To pass just the delegate, label the parameter

var result = client.MultiSearch(selector: ms => ms
    .Search<ElasticsearchProject>("projects", s => s.MatchAll())
    .Search<Person>("people", s => s.MatchAll())
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM