Search
Getting started with the product search api
Guidelines for Effective Product Retrieval
When retrieving products from Omnium, especially for e-commerce, consider the following:
-
Leverage Search Parameters
Use the various search parameters available withSearchProductsto tailor your queries effectively. This endpoint automatically gives you the "best" price for the product based on your search queries: It will filter prices onstoreId,marketId,customerId,customerGroupIdwhile also checking promotions filtering on active/inactive prices.
Keep in mind thatSearchProductsis not intended for deep pagination. If you are building an integration and need to fetch all products, you should use the scroll endpoints instead. -
Optimize Data Retrieval
Use theincludedFieldsandexcludedFieldsparameters to retrieve only necessary data. For example:- Do you need to fetch all product categories or custom properties?
- Could you exclude variants when searching for products on a product list page?
-
Predefined Property Lists
Utilize thePropertyListIdsearch parameter to predefine which custom properties to return, set up directly in the Omnium UI. -
Ensure Accurate Pricing
Use parameters likemarketId,storeId,customerId, andlanguageto get the correct price for returned products. -
Disable Unnecessary Features
Disable facets unless required for your search. This reduces payload size and improves server and client-side performance. -
Single Product Retrieval
Consider usingSearchProductsinstead ofGETwhen fetching individual products, particularly if you don’t need all product properties. This will also ensure that you get the right price for the product based on your search parameters, such asmarketIdorcustomerId. -
High-Frequency Products
For frequently loaded products, such as those visible on checkout or front pages, consider setting up caching with a short expiration time. -
Large scale queries
For large-scale queries (20,000+ products), typically for most integrations, avoid usingSearchProductsas this is not intended for deep pagination. Instead, useScrollProductsfor fetching all matching products.
Searching products
Search products using the SearchProducts endpoint:
A simple search object, with a free text search, fetching 10 first items.
Sort order
Products are not sorted by default. They are returned ordered by their document ID. To specify sort order, add sortOrder property to search request:
Sample query sorted by created date descending.
The following sort orders are available:
- CreatedAscending
- CreatedDescending
- BrandAscending
- BrandDescending
- AverageRatingAscending
- AverageRatingDescending
- ColorAscending
- ColorDescending
- NameAscending
- NameDescending
- SpecificationAscending
- SpecificationDescending
- SupplierNameAscending
- SupplierNameDescending
- SkuIdAscending
- SkuIdDescending
- CatalogAscending
- CatalogDescending
- PriceAscending
- PriceDescending
- InventoryAscending
- InventoryDescending
- IsInStockAscending
- IsInStockDescending
- CostPriceAscending
- CostPriceDescending
- ModifiedAscending
- ModifiedDescending
- LocationAscending
- LocationDescending
- PublishedAscending
- PublishedDescending
- SortIndexAscending
- SortIndexDescending
- PopularityDescending
- PopularityAscending
- DiscountPercentAscending
- DiscountPercentDescending
- ScoreDescending
- ParentIdAscending
- ParentIdDescending
Secondary and tertiary sort order
To add a secondary sort order, use the SortOrder2nd property in productSearchRequest. If it is used, the primary sort order (SortOrder) is required.
Sample query sorting by discount percent, and then by inventory.
To add a third sort order, use SortOrder3rd. If set, the primary (SortOrder) and secondary (SortOrder2nd) sort order are required.
Including and excluding fields
Excluding fields
There are two ways of excluding fields from product search:
- Using boolean values to exclude large properties:
- Excluding fields from a list of field names:
Sample query excluding categories from search result.
Include only selected fields
Exclude all fields except for ID. This would only be useful when used together with IncludedFields.
Sample query getting only the color field from the product.
Sort index threshold
Sort index can be used for setting a threshold for returning products through search. Typically used for showing the most important products in content blocks or limiting the assortment in product lists in general.
Sample query with sort index threshold 5.
Sort index value for a product is the sum of sortIndexBase and sortIndexBoost. The sortIndexBase is calculated by Omnium according to how many stores have the item in stock and how many stores have a price for that product.
In product settings, a boost value for promotion prices can be set by adding a value to omniumSortIndexProviderPromotionBoost. If a product has a price with a promotion, this value will be added to the sort index boost.
