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:
| Environment | Index Prefix | Example Product Index |
|---|---|---|
| Production | scottsdale_prod_ | scottsdale_prod_posts |
| Staging | scottsdale_stg_ | scottsdale_stg_posts |
| Local | scottsdale_local_v2_ | scottsdale_local_v2_posts |
Environment Variablesโ
| Variable | Description |
|---|---|
ALGOLIA_APPLICATION_ID | Algolia application ID (EYDBVK6XRL) |
ALGOLIA_ADMIN_API_KEY | Algolia admin key (used server-side only โ never in frontend code) |
ALGOLIA_SEARCH_API_KEY | Algolia search-only API key (safe for frontend use) |
ALGOLIA_PREFIX | Index name prefix (scottsdale_prod_ / scottsdale_stg_ / scottsdale_local_v2_) |
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 Type | Index | Notes |
|---|---|---|
| WooCommerce Products | {prefix}posts | Primary search index |
| WordPress Posts | {prefix}posts | News, blog posts |
| WordPress Pages | {prefix}posts (filtered) | Selected pages |
| Product categories | Facets within products index | Not a separate index |
Product Index Fieldsโ
Each product record in Algolia contains:
objectIDโ WordPress post IDpost_titleโ Product namepost_contentโ Product description (stripped of HTML)skuโ WooCommerce SKUpriceโ Current price (float)_product_image_urlโ Featured image URLpermalinkโ Product URLcategoriesโ 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 filteringtaxableโ Whether AvaTax applies
Search Featuresโ
Autocomplete / Instant Searchโ
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_postaction) - 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 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โ
| Issue | Action |
|---|---|
| Search not finding a product | Check the product is published and not password-protected; manually re-sync the product in Algolia admin |
| Wrong environment searched | Verify ALGOLIA_PREFIX is set correctly for current environment |
| Prices in search results are stale | Price updates trigger re-sync; check if the pricing webhook is running |
| Algolia admin key in JS | Audit ALGOLIA_ADMIN_API_KEY usage โ must only be in PHP/server-side code |
| InstantSearch not loading | Check JavaScript console; verify ALGOLIA_SEARCH_API_KEY and ALGOLIA_APPLICATION_ID in WP settings |