Search
This section describes how to build search queries for various common tasks under product catalog, and explains how to build a product filter.
For a general introduction to search, and for more examples refer to the articles in the "General section"
Search index names
The search index names that can be used in search query building in the product catalog are defined in the class Litium.Foundation.Modules.ProductCatalog.Search.ProductCatalogSearchDomains
Following are the list of index names:
- ArticleGroups :Use this index to search on article groups. The id of a hit in the search response will be the article group id.
- Articles:Use this index to search on articles. The id of a hit in the search response will be the article id.
- ArticleVariantGroups: Use this index to search on variant groups. The id of a hit in the search response will be the variant group id.
- Assortments: Use this index to search on the assortments. The id of a hit in the search response will be the assortment id.
- ProductCatalogModule: Use this index to search whole productalog for a particular term (excluding price lists). The id of a hit can either be an Article, ArticleGroup, Assortment, ProductGroup, Product or a VariantGroup.
- ProductGroups: Use this index to search on product groups. The id of a hit in the search response will be the product group id.
- Products: Use this index to search on products. The id of a hit in the search response will be the product id.
- ProductsAndProductGroups: Use this index to search both products and groups. Can be used to search for items where name might mean both a product as well as a product group. The id of a hit in the search response can either be a product or a product group.
- ProductSets: Use this index to seach on product sets. The id of a hit in the search response will be the product set id.
- VariantGroups: Use this index to search on variant groups. The id of a hit in the search response will be the variant group id.
Tag names
Tag names to use in a search query for product catalog are defined in the class Litium.Foundation.Modules.ProductCatalog.Search.TagNames. Most of their meaning is self explanatory by their name.
In following special instances, a static method in the above TagNames class returns the name to be used as the tag name.
- Search for a property field: use TagNamesGetTagNameForProperty()
- Search in a price list: use TagNames.GetTagNameForPriceExludingVAT() or TagNames.GetTagNameForPriceIncludingVAT()
- Search for article stock status in a warehouse: use TagNames.GetTagNameForWarehouseArticleStatus()
- Search for article Vat percentage from a price list: TagNames.GetTagNameForVATPercentage()
- Search for warehouse quantity: use TagNames.GetTagNameForWarehouseQuantity()
following example shows how to use the "Products" index described above to search for all products who has a common product group parent.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /// <summary>
/// Searches for products (and variant groups) under a product group.
/// </summary>
/// <param name="languageId">The language id.</param>
/// <param name="productGroupId">The product group id.</param>
/// <param name="token">The token.</param>
/// <returns></returns>
public static IEnumerable<Guid> SearchForProducts(Guid languageId, Guid productGroupId, SecurityToken token)
{
IEnumerable<Guid> result = null ;
var request = new QueryRequest(languageId, ProductCatalogSearchDomains.Products, token);
request.FilterTags.Add( new Tag(TagNames.ProductGroupTreeId, productGroupId));
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>();
}
|