Skip to main content

search

This query can be used to fetch information about search facets, products and suggestions according to a given search term.

Usage​

Arguments

first*Int
Description

Number of items that should return from the complete result list.

afterString
Description

Pagination argument, indicating the cursor corresponding to the item after which the results should be fetched.

sortStoreSort
Description

Search result sorting mode, where StoreSort is an Enum with one of the possible values: price_desc, price_asc, orders_desc, name_desc, name_asc, release_desc, discount_desc and score_desc.

termString
Description

Search term.

selectedFacetsIStoreSelectedFacet
Description

Array of search facets (IStoreSelectedFacet), each with key and value.

query ($first: Int!){
search (first: $first) {
product {
# StoreProductConnection fields
},
suggestions {
# StoreSuggestions fields
},
facets {
# StoreFacet fields
}
}
}

Example​

  • Get the keys, labels, label values, and value amounts from the first three facets in the search result from the wooden term.
query {
search (first:3, term:"wooden") {
facets {
key,
label,
values {
quantity
}
}
}
}
  • Get cursors, names, SKU IDs, and image URLs for the 10 products after the product with cursor 10 in the search from the steel term. Also, get the total quantity of results in the complete list and whether there are more results for next page.
query {
search (first: 10, after: "10", term:"steel") {
products {
pageInfo {
hasNextPage,
totalCount
},
edges {
node {
name,
sku,
image {
url
}
},
cursor
}
}
}
}
  • Get terms values, term counts, product names, and SKU IDs for the first five sugestions from a list sorted from higher to lower discount in the search result from the table term.
query {
search (first:5, sort: discount_desc, term:"table") {
suggestions {
terms {
value,
count
},
products {
name,
sku
}
}
}
}
  • Get information about facets, products and suggestions at once.
query {
search (first:5, after:"5", term:"wooden", sort:score_desc) {
products {
pageInfo {
totalCount,
hasNextPage,
endCursor
},
edges {
node {
name,
sku,
slug,
image {
url,
alternateName
}
},
cursor
}
},
suggestions {
terms {
value,
count
},
products {
name,
slug,
description
}
},
facets {
key,
label,
values {
value,
selected
},
type
}
}
}

Didn't find your answers? Ask the Community. For documentation suggestions, submit your feedback.

JOIN THE COMMUNITY