Range search

A typical range search would be a price range search or a search for new products published between certain dates.

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

Pay 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: 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!