Integrations / Platforms / Shopify / Index Schema

Our plugin formats your data in an optimal and extensible format so that it can better serve your Shopify search experience.

Algolia for Shopify is a Shopify Plus certified app. You can use it with your Shopify Plus or Shopify stores.

This page will explain how we format your data, how we configure your Algolia indexes, and how to exclude objects from your search results.

Products

Algolia does not directly store products: it stores variants. For products with variants, all variants are treated and uploaded as independent objects: the product itself is not uploaded. For products without variants, the attributes of the product are first put into a schema that parallels the structure of the variant’s schema, and then uploaded.

The Shopify integration only supports indexing products in the “Online Store” sales channel. Other channels are currently not supported.

Schema

Algolia stores your products in the following format:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
  objectID,                       // Variant id (unique identifier also used by Algolia)
  sku,
  barcode,
  id,                             // Product id
  title,                          // Name of the product
  variant_title,                  // Name of the variant
  product_type,
  vendor,
  handle,                         // URL handle for the product
  tags,
  named_tags: {                   // Key value association from tags like this: "key:value" (See Named tags section)
    <TAG_KEY>
  },
  body_html_safe,                 // Description (without HTML, truncated to 2000 characters)
  compare_at_price,               // Initial price
  price,                          // Actual (optionally discounted) price
  price_ratio,
  price_range,
  variants_count,                 // Total count of the variants of the related product
  variants_min_price,             // Min price of all the variants of the related product (only relevant with distinct enabled)
  variants_max_price,             // Max price of all the variants of the related product (only relevant with distinct enabled)
  option1,                        // Variant option 1
  option2,                        // Variant option 2
  option3,                        // Variant option 3
  options: {                      // Hash containing the option `names: value`
    <OPTION_NAME>
  },
  option_names,                   // Array containing the option names, in order
  requires_shipping,
  taxable,
  grams,
  weight,                         // Weight with its original unit
  image,
  product_image,
  inventory_management,           // Inventory management system used
  inventory_management_shopify,   // Is the inventory management system shopify (1 if yes, 0 if no)
  inventory_quantity,             // Number of available items in the inventory
  position,                       // Position of the variant in the list of products
  template_suffix,
  meta: {                         // Metafields (See Metafields section)
    namespace1: {
      key1,
      key2
    },
  },
  created_at,
  updated_at,
  published_at,
  recently_ordered_count,          // How much have recently been ordered : useful for ranking
  collections: [
    'collection-1-handle',         // Array of product collection handles
    ...
  ],
  collection_ids: [
    'collection-1-id',             // Array of product collection IDs
    ...
  ],
}

The image attribute uses the variant’s picture if it exists, the first picture of the associated product otherwise.

The recently_ordered_count attribute doesn’t exist when we first index products. Instead, we create and increment it as you sell products. If a customer orders two size S blue t-shirts, we increment the recently_ordered_count on this variant by two. We then use this attribute for the Most Popular sort order.

Whenever you run a full reindex, we reset the recently_ordered_count attribute for all products. In other words, recently_ordered_count is a count of all orders since the last reindex, not for all time. However, we preserve the attribute during real-time indexing.

Searchable Attributes

By default, we perform textual search on the following attributes (they are ranked in order of importance):

  1. vendor
  2. title
  3. variant_title
  4. product_type
  5. tags
  6. handle
  7. sku
  8. barcode
  9. body_html_safe

Displaying by product/most relevant variant

To have only the most relevant variant appear in your search results instead of all variants, select the Show Products option from the Display tab.

Skipping a product

Products are indexed if they’re:

  • Published (denoted as “Active” within the Shopify admin interface), and
  • aren’t set to be “Active” or “Published” in the future, and
  • don’t have algolia-ignore in their list of tags, and
  • don’t have [hidden] in their title (lowercase, with brackets).

To remove or hide a product from search results (for example, a private product or a product not yet ready for sale), either:

  1. Add algolia-ignore to its list of tags, or
  2. add [hidden] to its name (lowercase, with brackets), or
  3. set it to “Inactive”.

Skipping a variant

To remove a variant from the search results add [hidden] to its name.

Example: for the color option, a variant name could be “blue”. Call it blue [hidden] or [hidden] blue to avoid indexing it.

The position of the phrase [hidden] does not matter. It can be at the beginning, middle, or end of the name.

Collections

Algolia directly stores your collections within a dedicated index.
If the “Collection Pages” feature has been turned on, the product-collection relationship is stored within the product records, and not the collection records, within the collection_ids (list of collection IDs) and collections (list of collection handles) attributes.

The Shopify integration only supports indexing collections in the “Online Store” sales channel. Other channels are currently not supported.

Schema

Algolia stores your collections in the following format:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  objectID,           // Collection id (in Shopify & Algolia)
  title,
  handle,             // URL handle
  body_html,          // Description (with HTML, truncated to 2000 characters)
  body_html_safe,     // Description (without HTML, truncated to 2000 characters)
  image,
  products_count,     // Product count in the collection (not updated in real time)
  template_suffix,
  meta: {             // Metafields (See Metafields section)
    namespace1: {
      key1,
      key2
    },
  },
  updated_at
}

Searchable attributes

We perform textual search on the following attributes (they are ranked by importance):

  1. title
  2. handle
  3. body_html_safe

Skipping a collection

Collections are indexed if they’re:

  • Published (denoted as “Active” within the Shopify admin interface), and
  • aren’t set to be “Active” or “Published” in the future, and
  • don’t have [hidden] in their title (lowercase, with brackets), and
  • contain at least 1 product.

To remove a collection from the search results, add [hidden] to its name on Shopify (lowercase, with brackets). This action prevents the collection from being indexed in the collections index.

Although we won’t index a collection with [hidden] in its name to the “collections” index, we still index the products in that collection to the “products” index.

For example, for a collection named Summer, call it Summer [hidden] or [hidden] Summer to prevent indexing it.

Articles

We store your Shopify Articles in Algolia as follows:

Schema

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  objectID,           // Article id (in Shopify & Algolia)
  title,
  handle,             // URL handle
  body_html,          // Description (with HTML, truncated to 2000 characters)
  body_html_safe,     // Description (without HTML, truncated to 2000 characters)
  image,
  tags,
  created_at,
  updated_at,
  meta: {

  },
  author: {
    objectID,
    name
  },
  blog: {
    objectID,
    title,
    handle,
    commentable,
    feedburner,
    feedburner_location,
    created_at,
    updated_at,
    meta
  }
}

Searchable attributes

We perform textual search on the following attributes (they are ranked by importance):

  1. title
  2. handle
  3. tags
  4. blog.title
  5. blog.handle
  6. author.name
  7. body_html_safe

Skipping an article

To remove an article from the search results, either:

  1. Add algolia-ignore to its list of tags
  2. Add [hidden] to its name (lowercase, with brackets)

Skipping a blog entirely

Articles belong to blogs. You can remove all the articles of a specific blog from the search results. To do so, add [hidden] to the blog name.

Pages

We store your Shopify Pages in Algolia as follows:

Schema

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  title,
  author,
  created_at,
  body_html,
  objectID,
  updated_at,
  meta,
  handle,
  shop_id,
  template_suffix,
  published_at,
  body_html_safe,
}

Ignoring a page

To remove a page from the search results, add “[hidden]” to its title (lowercase, between brackets).

To prevent the “[hidden]” phrase from being visible on the website, you can replace {{ page.title }} with {{ page.title | replace: "[hidden]", "" }}. This utilizes Liquid’s replace method to remove [hidden] from the title.

Did you find this page helpful?