Reputation: 5611
I would like to do a request on several types with a SearchRequest object
My request would look like to the code bellow:
var searchQuery = new BoolQuery
{
Should = shouldContainers,
Filter = filterContainers
};
var searchRequest = new SearchRequest<dynamic>()
{
//Don't know how to target type
Type = EType.All,
//or
Type = typeof(obj1) && typeof(obj2)
Query = searchQuery,
Size = size
From = fromNumber,
MinScore = 1
};
var response = await client.SearchAsync<dynamic>(searchRequest);
Do you know if it is possible to do something like that and how to do this?
Upvotes: 0
Views: 390
Reputation: 982
If you don't specify the index/type in the endpoint, it will search the whole cluster.
Update:
//
// Summary:
// /_search
//
// Parameters:
// document:
// describes an elasticsearch document of type T, allows implicit conversion from
// numeric and string ids
public SearchRequest();
//
// Summary:
// /{index}/_search
//
// Parameters:
// index:
// Optional, accepts null
public SearchRequest(Indices index);
//
// Summary:
// /{index}/{type}/_search
//
// Parameters:
// index:
// Optional, accepts null
//
// type:
// Optional, accepts null
public SearchRequest(Indices index, Types type);
// The second one is what you are looking for, query on specific index regardless type, it does `POST /{index}/_search`
var searchRequest = new SearchRequest(myIndex){...}
var result = client.Search<dynamic>(searchRequest);
Upvotes: 1