Skip to main content

Algolia Search

Scottsdale Mint uses Algolia to power site-wide product search and category browsing. Algolia provides near-instant search results with typo tolerance, filters, and faceted navigation โ€” capabilities not available in WordPress's default search.


Pluginโ€‹

  • Plugin: algolia/algolia-woocommerce (or the standard WP Search with Algolia plugin from WebDevStudios)
  • Application ID: EYDBVK6XRL

Index Namesโ€‹

Index names are environment-specific, determined by the ALGOLIA_PREFIX environment variable:

EnvironmentIndex PrefixExample Product Index
Productionscottsdale_prod_scottsdale_prod_posts
Stagingscottsdale_stg_scottsdale_stg_posts
Localscottsdale_local_v2_scottsdale_local_v2_posts

Environment Variablesโ€‹

VariableDescription
ALGOLIA_APPLICATION_IDAlgolia application ID (EYDBVK6XRL)
ALGOLIA_ADMIN_API_KEYAlgolia admin key (used server-side only โ€” never in frontend code)
ALGOLIA_SEARCH_API_KEYAlgolia search-only API key (safe for frontend use)
ALGOLIA_PREFIXIndex name prefix (scottsdale_prod_ / scottsdale_stg_ / scottsdale_local_v2_)
Never Expose Admin Key

The ALGOLIA_ADMIN_API_KEY must never appear in frontend JavaScript or HTML source. It has full write access to the Algolia index. Use only ALGOLIA_SEARCH_API_KEY in frontend code.


What is Indexedโ€‹

Content TypeIndexNotes
WooCommerce Products{prefix}postsPrimary search index
WordPress Posts{prefix}postsNews, blog posts
WordPress Pages{prefix}posts (filtered)Selected pages
Product categoriesFacets within products indexNot a separate index

Product Index Fieldsโ€‹

Each product record in Algolia contains:

  • objectID โ€” WordPress post ID
  • post_title โ€” Product name
  • post_content โ€” Product description (stripped of HTML)
  • sku โ€” WooCommerce SKU
  • price โ€” Current price (float)
  • _product_image_url โ€” Featured image URL
  • permalink โ€” Product URL
  • categories โ€” Array of category names/slugs
  • _metal_type โ€” Gold, Silver, Platinum, Palladium (for faceting)
  • _metal_weight_troy_oz โ€” For filtering by weight
  • _in_stock โ€” Boolean for availability filtering
  • taxable โ€” Whether AvaTax applies

Search Featuresโ€‹

The site implements InstantSearch.js (Algolia's frontend library) on the search bar:

  • Typeahead suggestions appear as the customer types
  • Results ranked by Algolia's relevance algorithm
  • Facets available for metal type, price range, product category

Full-Text Search Results Pageโ€‹

The search results page (/search/) uses Algolia InstantSearch with:

  • Product grid sorted by relevance
  • Sidebar facets: Metal Type, Price Range, Weight, In Stock
  • Pagination (infinite scroll or page numbers)
  • "No results" fallback with suggestions

Index Synchronizationโ€‹

Automatic Syncโ€‹

Products are synced to Algolia automatically when:

  • A product is saved (save_post action)
  • A product's price is updated (via the pricing pipeline, which triggers a post meta save)
  • A product is trashed or deleted (removed from index)

Manual Re-Indexโ€‹

To re-index all products:

wp algolia re-index --network
# Or via the WP admin: Algolia โ†’ Indices โ†’ "Re-index All"
Re-indexing on Production

Re-indexing all products on production replaces the index atomically (Algolia swaps indices when complete). This is safe but can take several minutes for large catalogs. Price updates continue working during re-index.


Patches Appliedโ€‹

The suma-patches plugin includes Algolia-related modifications:

// Modifications to search result ranking or attribute indexing
// to prioritize precious metals product fields

Refer to web/app/mu-plugins/suma-patches/ for the specific Algolia hooks.


Algolia Insights (Analytics)โ€‹

Algolia Insights tracks:

  • Which search queries lead to product views
  • Which products are clicked from search results
  • Which products are purchased after a search

This data feeds into Algolia's Click-Through Rate metrics and helps improve ranking.


Troubleshootingโ€‹

IssueAction
Search not finding a productCheck the product is published and not password-protected; manually re-sync the product in Algolia admin
Wrong environment searchedVerify ALGOLIA_PREFIX is set correctly for current environment
Prices in search results are stalePrice updates trigger re-sync; check if the pricing webhook is running
Algolia admin key in JSAudit ALGOLIA_ADMIN_API_KEY usage โ€” must only be in PHP/server-side code
InstantSearch not loadingCheck JavaScript console; verify ALGOLIA_SEARCH_API_KEY and ALGOLIA_APPLICATION_ID in WP settings