Skip to main content

WP Search with Algolia

The WP Search with Algolia plugin powers the Dealers Site's product search and browse experience, integrating the WordPress frontend with the Algolia search service.


Plugin Details

PropertyValue
PluginWP Search with Algolia
Locationplugins/wp-search-with-algolia/
Algolia LibraryAlgolia PHP API Client

What Gets Indexed

The plugin indexes the following content types:

Index TypeContent
ProductsAll published WooCommerce products including meta, categories, tags, and pricing
Posts (non-products)Pages and posts (via the custom Algolia_Searchable_Posts_Index_Not_Products class)

Product Index Attributes

Each Algolia product record contains attributes from the Plugins' default schema plus custom attributes added by the WooCommerce store and the Middleware pricing sync:

  • objectID — WooCommerce product ID
  • sku — Product SKU
  • post_title — Product name
  • categories — Array of WooCommerce category names
  • tags — Array of WooCommerce tags
  • regular_price — Current ask price (updated by Middleware pricing sync)
  • retail_tiers — Volume pricing tiers (updated by Middleware pricing sync)
  • _thumbnail_id / images — Product images

Theme Integration

The Suma Elementor theme's Algolia class (inc/class-algolia.php) extends the plugin's functionality:

  • Customises which product attributes are included in the index record
  • Adds custom data transformation before indexing

The AlgoliaCustomSearch class (inc/class-algolia-custom-search.php) registers a separate Algolia index for non-product posts, ensuring the product pricing index is kept clean.


On search pages (is_search() returns true), the theme loads the Algolia InstantSearch.js library:

if ( is_search() && defined( 'ALGOLIA_VERSION' ) ) {
wp_enqueue_script( 'algolia-instantsearch' );
wp_enqueue_style( 'algolia-instantsearch' );
}

InstantSearch.js renders results client-side with live filtering and pricing display.


Re-indexing

To re-index all products (e.g., after a bulk product import):

# Via WP-CLI
wp algolia re-index --index_name=products

# Via WP Admin
# Navigate to Algolia → Indexing → Re-Index

Configuration

Algolia credentials are in wp-config.php:

define( 'ALGOLIA_APP_ID',  'XXXXXXXXXX' );
define( 'ALGOLIA_API_KEY', 'xxxxxxxx' ); // Search-only key (public)

Admin API key for indexing/management is configured in WP Admin → Algolia → Settings → API.