Search
Product search and discovery
Performs a full-text search across products with support for faceted filtering, sorting, and pagination. Returns matching products along with available filter facets and sorting options.
How Search Works:
When a search request is received, the system first checks if the same search with identical parameters has been performed recently. If found in cache, results are returned immediately.
If no cached result is found, the search process begins. The system queries Elasticsearch, which stores product metadata (not full product data). The fields used for querying include: in_stock, price, basket_offer_ids, category_ids, and collection_ids.
Product Extraction Strategies:
After receiving results from Elasticsearch, products are extracted using one of the following strategies:
DefaultProductExtractionStrategy: Returns all product IDs that matched the search
FirstItemSearchExtractionStrategy: Returns the first sub-product from each meta product
ListableFirstProductExtractionStrategy: Returns listable products when meta products contain sub-products
MinPriceFirstProductExtractionStrategy: Returns sub-products sorted by minimum price in ascending order
MaxPriceFirstProductExtractionStrategy: Returns sub-products sorted by maximum price in ascending order
AllSubProductsExtractionStrategy: Returns all sub-product IDs belonging to meta products
Product and Facet Conversion:
After extraction, two conversion processes occur:
Product Conversion: Product IDs from Elasticsearch are fetched from the database in the order they were returned, maintaining search relevance ordering
Facet Conversion: Facet data (filterable attribute IDs) is used to fetch attribute values from the database and create filter widgets. Widget types are determined by
FacetConfigurationdatabase records:If a Facet Configuration exists for the attribute, it specifies the widget type, aggregation settings, and display options
If no Facet Configuration exists, fallback rules apply:
category_idsuses Category Widgetbasket_offer_idsuses Promotion WidgetAll other attributes default to Multi Select Widget
Widget configurations support translation for multi-language sites
Widgets include choices with quantities, labels, selection states, and URLs for filtering
Filtering Support:
The search supports filtering by various attributes including:
Stock availability (in_stock)
Price ranges (price)
Categories (category_ids)
Collections (collection_ids)
Sellers (seller_ids)
Basket offers (basket_offer_ids)
Discount amounts and ratios (discount_amount, discount_ratio)
Category paths (category_paths)
Custom product attributes (attributes_*)
Custom fields (custom_*)
Pagination and Sorting:
Results are paginated and can be sorted using available sort options. The default page size is configurable via the SEARCH_DEFAULT_PAGE_SIZE dynamic setting and can be overridden via the page_size parameter. Maximum page size is limited to 250 items.
Sort options are configured through the SortOption database model and managed via the administration interface. Each sort option defines:
Display label (translatable)
Parameter value used in the
sorterquery parameterElasticsearch sort configuration (field paths, directions, nested queries)
Display order and visibility settings
When a sort option is selected, its Elasticsearch configuration is applied to the search query. Sort options automatically adapt to inventory strategy context, adjusting price field references when multiple price lists are active. A secondary sort by product listing ID ensures consistent ordering across pages.
Fuzzy Search:
When fuzzy search is enabled (SEARCH_FUZZY_SEARCH_ACTIVE) and the query is longer than 4 characters, the search includes approximate matches with typo tolerance (fuzziness level: 1).
Search query text
{"value":"smartwatch","summary":"Single word search"}Page number (1-indexed)
{"value":1,"summary":"First page"}Number of results per page. Maximum value is 250. If not specified, the default page size from SEARCH_DEFAULT_PAGE_SIZE dynamic setting is used.
{"value":20,"summary":"Standard page size"}Sort option value
{"value":"default","summary":"Default sorting"}Default page size for pagination. This value is used when page_size parameter is not provided. The actual page size will be the minimum of this value and the maximum allowed page size (250). If not provided, uses the SEARCH_DEFAULT_PAGE_SIZE dynamic setting value
20Custom Elasticsearch sort value to override or extend the default sorting behavior. When provided, this value is prepended to the selected sorter's Elasticsearch value. Can be a single value or comma-separated list of values. Used for advanced sorting customization in Elasticsearch queries
_scoreProduct extraction strategy class path. Determines how products are extracted from Elasticsearch results, especially when dealing with meta products and sub-products. If not provided, uses the value from SEARCH_PRODUCT_EXTRACTION_STRATEGY dynamic setting, or defaults to DefaultProductExtractionStrategy. Available strategies:
- DefaultProductExtractionStrategy: Returns all matching product IDs
- FirstItemSearchExtractionStrategy: Returns first sub-product from each meta product
- ListableFirstProductExtractionStrategy: Returns listable products when meta products contain sub-products
- MinPriceFirstProductExtractionStrategy: Returns sub-products sorted by minimum price (ascending)
- MaxPriceFirstProductExtractionStrategy: Returns sub-products sorted by maximum price (ascending)
- AllSubProductsExtractionStrategy: Returns all sub-product IDs belonging to meta products
omnishop.search.strategies.DefaultProductExtractionStrategyInventory strategy identifier. Used in shops with multiple inventory systems to determine which price list should be used. When provided, price fields are prefixed with the price list ID (e.g., price_1234 instead of price). If not provided, uses the basket's inventory strategy or defaults to the standard inventory
1234Filter by stock availability (comma-separated values)
{"value":["true"],"summary":"Filter for in-stock products only"}Filter by price range (comma-separated values)
{"value":["0","100"],"summary":"Price range from 0 to 100"}Filter by category identifiers (comma-separated)
{"value":[14],"summary":"Filter by single category"}Filter by collection identifiers (comma-separated)
{"value":[5],"summary":"Filter by single collection"}Filter by seller/data source identifiers (comma-separated)
Filter by basket offer/promotion identifiers (comma-separated)
{"value":[100],"summary":"Filter by single promotion"}Filter by discount amount range (comma-separated min, max)
{"value":["0","50"],"summary":"Discount amount from 0 to 50"}Filter by discount ratio range (comma-separated min, max)
{"value":["0","30"],"summary":"Discount ratio from 0% to 30%"}Filter by category paths (comma-separated)
{"value":["000100010001"],"summary":"Filter by single category path"}Data retrieval mode. When set to "facets", only facet data is returned. When set to "products", only product data is returned. When not specified, both facets and products are returned.
{"value":"facets","summary":"Retrieve only facets"}Possible values: Search results retrieved successfully
Search results retrieved successfully
Last updated
Was this helpful?

