var client = new ElasticClient();
var response = client.MultiSearchTemplate(ms => ms
.Template<object>("template_1", st => st
.AllIndices()
.AllTypes()
.Id("t1")
.Params(d => d
.Add("field", "Envrionment")
.Add("value", "Test")
)
)
.Template<object>("template_2", st => st
.AllIndices()
.AllTypes()
.Id("t1")
.Params(d => d
.Add("field", "Envrionment")
.Add("value", "Test")
)
)
);
var firstSearchResponse = response.GetResponse<object>("template_1");
var secondSearchResponse = response.GetResponse<object>("template_2");
I've used object here to represent the type to which the documents in each search will be deserialized into, but you can use whatever class makes sense.
This will send the following request
POST http://localhost:9200/_msearch/template
{"index":"_all"}
{"id":"t1","params":{"field":"Envrionment","value":"Test"}}
{"index":"_all"}
{"id":"t1","params":{"field":"Envrionment","value":"Test"}}
Note that NEST inserts the "_all" index name for all indices, which should act the same as not specifying the index.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.