nest elasticsearch:如何在 SearchRequest 对象中定位多种类型?
nest elasticsearch : how to target multi types in SearchRequest Object?
我想使用 SearchRequest 对象对多种类型进行请求
我的请求类似于下面的代码:
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);
你知道是否可以做这样的事情以及如何做?
如果您不在端点中指定 index/type,它将搜索整个集群。
更新:
//
// 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);
我想使用 SearchRequest 对象对多种类型进行请求
我的请求类似于下面的代码:
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);
你知道是否可以做这样的事情以及如何做?
如果您不在端点中指定 index/type,它将搜索整个集群。
更新:
//
// 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);