Skip to content

Search Products

About

The searchProducts query enables advanced product search with support for text queries, filtering, and sorting. Use this query to:

  • Implement full-text product search functionality
  • Build auto-complete and suggestion interfaces
  • Filter products by multiple criteria (price range, categories, attributes)
  • Sort search results by relevance, price, date, or custom fields
  • Implement faceted search interfaces
  • Create advanced query-based product discovery

The search supports Bagisto's advanced search syntax for building complex, multi-criteria queries. It efficiently ranks results by relevance while maintaining performance across large product catalogs.

Arguments

ArgumentTypeDescription
queryStringSearch term or advanced query string. Searches product name, description, SKU, and other fields.
firstIntMaximum number of results per page (default: 20, max: 250).
afterStringCursor for pagination. Returns results after this cursor.
lastIntMaximum results for backward pagination (max: 250).
beforeStringCursor for backward pagination.
sortKeyProductSortKeysSort results by: RELEVANCE, TITLE, PRICE, CREATED_AT, POPULARITY. Default: RELEVANCE
reverseBooleanReverse sort order. Default: false
filtersProductFilterInputAdvanced filters for price range, categories, tags, and custom attributes.
filterStringJSON-encoded filter string. Supports keys like category_id to filter products by category (e.g. "{\"category_id\": \"22\"}")

Possible Returns

FieldTypeDescription
edges[ProductEdge!]!Search result edges containing product nodes and pagination cursors.
edges.nodeProduct!Product object with all searchable fields (name, description, SKU, tags).
edges.node.scoreFloatRelevance score of the product match (0-1). Higher scores indicate better matches.
edges.cursorString!Pagination cursor for this result.
nodes[Product!]!Simplified array of products without edge wrapping.
pageInfoPageInfo!Pagination metadata.
pageInfo.hasNextPageBoolean!True if more results available after current page.
pageInfo.endCursorStringCursor of last result on page.
facets[SearchFacet!]Available facets for filtering (categories, price ranges, attributes).
facets.nameString!Facet name (e.g., "category", "price_range").
facets.values[FacetValue!]!Available values and counts for this facet.
totalCountInt!Total matching products across all pages.

Filter Reference

The filter argument accepts a JSON-encoded string. You can combine multiple filters in a single object.

Available Filter Keys

Filter KeyTypeDescriptionExample
category_idStringFilter by category ID"{\"category_id\": \"22\"}"
typeStringFilter by product type (simple, configurable, virtual, downloadable, grouped, bundle)"{\"type\": \"configurable\"}"
colorStringFilter by color attribute option ID"{\"color\": \"3\"}"
sizeStringFilter by size attribute option ID"{\"size\": \"1\"}"
brandStringFilter by brand attribute option ID"{\"brand\": \"5\"}"
newStringFilter for new products only"{\"new\": \"1\"}"
featuredStringFilter for featured products only"{\"featured\": \"1\"}"

Combining Filters

Pass multiple keys in a single JSON object:

graphql
products(filter: "{\"color\": \"5\", \"size\": \"1\", \"brand\": \"5\"}")

Sorting Reference

Use sortKey and reverse to control result ordering:

SortsortKeyreverseDescription
A → Z"TITLE"falseAlphabetical ascending
Z → A"TITLE"trueAlphabetical descending
Newest First"CREATED_AT"trueMost recently created
Oldest First"CREATED_AT"falseEarliest created
Cheapest First"PRICE"falseLowest price first
Most Expensive First"PRICE"trueHighest price first

REST API Equivalents

Use CaseREST EndpointGraphQL Equivalent
New Products/api/products?new=1&sort=asc&limit=10products(filter: "{\"new\": \"1\"}", sortKey: "CREATED_AT", reverse: false, first: 10)
Featured Products/api/products?sort=created_at-desc&limit=12products(filter: "{\"featured\": \"1\"}", sortKey: "CREATED_AT", reverse: true, first: 12)
Popular by Brand/api/products?sort=created_at-desc&brand=25&limit=12products(filter: "{\"brand\": \"25\"}", sortKey: "CREATED_AT", reverse: true, first: 12)
All (Price Desc)/api/products?sort=price-desc&limit=12products(sortKey: "PRICE", reverse: true, first: 12)

Released under the MIT License.