# predictiveSearch - storefront - QUERY Version: 2024-10 ## Description List of the predictive search results. ### Access Scopes ## Arguments * [limit](/docs/api/storefront/2024-10/scalars/Int): Int - Limits the number of results based on `limit_scope`. The value can range from 1 to 10, and the default is 10. * [limitScope](/docs/api/storefront/2024-10/enums/PredictiveSearchLimitScope): PredictiveSearchLimitScope - Decides the distribution of results. * [query](/docs/api/storefront/2024-10/scalars/String): String! - The search query. * [searchableFields](/docs/api/storefront/2024-10/enums/SearchableField): SearchableField - Specifies the list of resource fields to use for search. The default fields searched on are TITLE, PRODUCT_TYPE, VARIANT_TITLE, and VENDOR. For the best search experience, you should search on the default field set. The input must not contain more than `250` values. * [types](/docs/api/storefront/2024-10/enums/PredictiveSearchType): PredictiveSearchType - The types of resources to search for. The input must not contain more than `250` values. * [unavailableProducts](/docs/api/storefront/2024-10/enums/SearchUnavailableProductsType): SearchUnavailableProductsType - Specifies how unavailable products are displayed in the search results. ## Returns * [articles](/docs/api/storefront/2024-10/objects/Article): Article! The articles that match the search query. * [collections](/docs/api/storefront/2024-10/objects/Collection): Collection! The articles that match the search query. * [pages](/docs/api/storefront/2024-10/objects/Page): Page! The pages that match the search query. * [products](/docs/api/storefront/2024-10/objects/Product): Product! The products that match the search query. * [queries](/docs/api/storefront/2024-10/objects/SearchQuerySuggestion): SearchQuerySuggestion! The query suggestions that are relevant to the search query. ## Examples ### Retrieve predictive search results Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query suggestions($query: String!) { predictiveSearch(query: $query) { queries { text } collections { id } products { id } pages { id } articles { id } } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query suggestions($query: String!) {\n predictiveSearch(query: $query) {\n queries {\n text\n }\n collections {\n id\n }\n products {\n id\n }\n pages {\n id\n }\n articles {\n id\n }\n }\n }`,\n});\n" Ruby example: null Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query suggestions($query: String!) {\n predictiveSearch(query: $query) {\n queries {\n text\n }\n collections {\n id\n }\n products {\n id\n }\n pages {\n id\n }\n articles {\n id\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query suggestions($query: String!) {\n predictiveSearch(query: $query) {\n queries {\n text\n }\n collections {\n id\n }\n products {\n id\n }\n pages {\n id\n }\n articles {\n id\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "predictiveSearch": { "queries": [ { "text": "snowboard" }, { "text": "oxygen snowboard" }, { "text": "3d snowboard" }, { "text": "huebert hydroxy snowboard" } ], "collections": [ { "id": "gid://shopify/Collection/1" } ], "products": [ { "id": "gid://shopify/Product/1" }, { "id": "gid://shopify/Product/2" }, { "id": "gid://shopify/Product/3" } ], "pages": [ { "id": "gid://shopify/Page/1" } ], "articles": [ { "id": "gid://shopify/Article/1" } ] } } }