FilterContainer在Elasticsearch NEST 5.0
我对Elasticsearch迁移工作从1.7.1到5.0。 我修复了大部分的代码问题升级到5.0之后,但我无法弄清楚如何改变FilterContainer在新版本中工作。FilterContainer在Elasticsearch NEST 5.0
下面是我的代码
public static List<FilterContainer> GetPriceRangeFilters(SearchListCriteria criteria, out List<FilterContainer> additionalpricefilters) {
var pricefilters = new List<FilterContainer>();
additionalpricefilters = new List<FilterContainer>();
if (criteria.SearchGlobalSettings.MinimumPriceRange != null && criteria.SearchGlobalSettings.MinimumPriceRange.Length > 0)
{
const string fieldName = "itemPrices.webPrice";
pricefilters.Add((new FilterDescriptor<ItemSearchEntry>()).Query(a => a.Range(n => n.OnField(fieldName).GreaterOrEquals(criteria.SearchGlobalSettings.MinimumPriceRange[0].ToString()).
LowerOrEquals(criteria.SearchGlobalSettings.MaximumPriceRange[0].ToString()))));
for (var i = 1; i < criteria.SearchGlobalSettings.MinimumPriceRange.Length; i++)
{
additionalpricefilters.Add((new FilterDescriptor<ItemSearchEntry>()).Query(a => a.Range(n => n.OnField(fieldName).
GreaterOrEquals(criteria.SearchGlobalSettings.MinimumPriceRange[i].ToString()).LowerOrEquals(criteria.SearchGlobalSettings.MaximumPriceRange[i].ToString()))));
}
}
return pricefilters;
}
回答:
FilterContainer
在NEST 2.0起,because filters and queries merged in Elasticsearch into queries不再存在,具有查询或过滤上下文。
如果你要使用FilterContainer
,使用QueryContainer
然后加入到搜索时,传递的FilterContainer
收集到bool
查询filter
条款。
以上是 FilterContainer在Elasticsearch NEST 5.0 的全部内容, 来源链接: utcz.com/qa/259244.html