Range search

This article describes how to search on a range of values. A common search in this area can be a price range search or search for news articles by date range by published date.

To make a range search, include the "RangeTag" to the filter tags of the search query. Following example searches for all products on a given price range inside a price list.

Give special attention to how the price list tag name is obtained.

using System;
using System.Collections.Generic;
using System.Linq;
using Litium.Foundation;
using Litium.Foundation.Modules.ProductCatalog.Search;
using Litium.Foundation.Search;
using Litium.Foundation.Security;
using Litium.Framework.Search;

public class RangeSearch
    /// <summary>
    ///     Search for list of products in a price range in the given pricelist
    /// </summary>
    public static IEnumerable<Guid> PriceRangeSearch(Guid languageId, Guid priceListId, decimal minPrice, decimal maxPrice, SecurityToken token)
        IEnumerable<Guid> result = null;
        var request = new QueryRequest(languageId, ProductCatalogSearchDomains.Products, token);
        var priceListTagName = TagNames.GetTagNameForPriceExludingVAT(priceListId);
        request.FilterTags.Add(new RangeTag(priceListTagName, minPrice, maxPrice));
        var response = Solution.Instance.SearchService.Search(request);

        if (response.Hits != null)
            result = response.Hits.Select(x => new Guid(x.Id));
        return result ?? new List<Guid>();

Note that in practice the final list price of an article may depend on other factors such as product campaigns or ERP pricing.

Is this page helpful?
Thank you for your feedback!