I am working on Elasticsearch migration from 1.7.1 to 5.0.
I fixed most of the issues in the code after upgrading to 5.0 but I couldn't figure out how to change FilterContainer to work in new version.
Below is my code
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;
}