Skip to content

DEVDOCS-6385 - Multi-lang text search #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions docs/storefront/headless/products/multi-language-search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: Multi-language Product Search with GraphQL
description: Learn how to perform product searches in multiple languages using the Storefront GraphQL API.
keywords: multi language, graphql, product search, translations
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [remark-lint] reported by reviewdog 🐶
Hard to read sentence (confidence: 4/7) retext-readability retext-readability

---

# Multi-language Product Search with GraphQL

BigCommerce's Storefront GraphQL API enables merchants to deliver localized shopping experiences by supporting multi-language product search. This guide explains how to use the API to search for products in a shopper's preferred language.

## Overview

To enable multi-language product search, ensure your store has both:
- Translated product names and descriptions
- Multi-language settings enabled in the BigCommerce admin

When these are set, the Storefront GraphQL API automatically returns product search results in the shopper's preferred language, determined by the `Accept-Language` HTTP header or customer settings. If no preference is provided, the store's default language is used. The API uses the request's locale to select the correct translations for product fields, so no special query arguments are needed.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [remark-lint] reported by reviewdog 🐶
Hard to read sentence (confidence: 4/7) retext-readability retext-readability


## Searchable Fields

The following fields are included in the multi-language search index:
- Product name
- Product description
- Variant option names and values (when present)
- Custom field names and values (when present)

Search terms match these fields in the selected language.

## Example Query

<Tabs items={['Request', 'Response']}>
<Tab>

```graphql filename="Example query: Search for Products" showLineNumbers copy
query SearchProductsInLanguage {
search {
searchProducts(filters: { searchTerm: "shirt" }) {
products(first: 10) {
edges {
node {
entityId
name
description
customFields {
name
value
}
options {
displayName
values {
label
}
}
}
}
}
}
}
}
```

</Tab>
<Tab>

```json filename="Example response: Search for Products" showLineNumbers copy
{
"data": {
"search": {
"searchProducts": {
"products": {
"edges": [
{
"node": {
"entityId": 123,
"name": "Chemise",
"description": "Chemise en coton pour homme.",
"customFields": [
{ "name": "Matière", "value": "Coton" }
],
"options": [
{
"displayName": "Taille",
"values": [{ "label": "M" }, { "label": "L" }]
}
]
}
}
]
}
}
}
}
}
```

</Tab>
</Tabs>

## Best Practices

- Set the shopper's language in your client (e.g., using the `Accept-Language` HTTP header).
- Translate all product content in the BigCommerce admin for complete localization.
- Test search results in each supported language to verify accuracy.

## Learn More

- [Faceted Textual Search](./faceted-textual-search)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [remark-lint] reported by reviewdog 🐶
Link to ./faceted-textual-search is dead no-dead-urls remark-lint

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [remark-lint] reported by reviewdog 🐶
Link to unknown file: faceted-textual-search missing-file remark-validate-links

- [Storefront GraphQL API Reference](https://developer.bigcommerce.com/docs/storefront/graphql)