Skip to content

Search with ElasticElasticsearch integration for Craft CMS

Provides Elasticsearch-powered search functionality with real-time indexing for Craft CMS.

INFO

These docs were written by AI and may contain errors. Please report any issues or inconsistencies.

Supported Content Types

Search with Elastic indexes the following Craft content types:

  • Entries - All entry types with configurable status filtering
  • Assets - Files with content extraction from PDFs and documents
  • Categories - Category trees with hierarchical search
  • Commerce Products - Product catalog with variant support
  • Digital Products - Digital product collections

Installation

shell
composer require pennebaker/craft-searchwithelastic
shell
ddev composer require pennebaker/craft-searchwithelastic
ddev add-on get ddev/ddev-elasticsearch
shell
docker-compose exec web composer require pennebaker/craft-searchwithelastic

Getting Started

See the Quick Start Guide for setup instructions.

Available Search Methods

Template Variables

The plugin provides template variables for searching:

twig
{# Basic search #}
{% set results = craft.searchWithElastic.search(query) %}

{# Advanced search with options #}
{% set results = craft.searchWithElastic.searchExtra(query, {
    fuzzy: true,
    fields: ['title', 'content'],
    size: 20
}) %}

Configuration Options

  • Authentication: Optional authentication for Elasticsearch
  • Rate Limiting: Configurable rate limits when enabled
  • Index Management: CLI commands and control panel utilities

System Requirements

  • Craft CMS 4.x
  • PHP 8.x
  • Elasticsearch 7.x or 8.x

View detailed requirements →

Getting Started

1. Install & Configure

php
// config/search-with-elastic.php
return [
    'elasticsearchEndpoint' => getenv('ELASTICSEARCH_ENDPOINT'),
    'isAuthEnabled' => true,
    'username' => getenv('ELASTICSEARCH_USERNAME'),
    'password' => getenv('ELASTICSEARCH_PASSWORD'),
];

2. Index Your Content

bash
# Via CLI
./craft search-with-elastic/index/reindex-all

# Or via Control Panel
# Utilities → Refresh Elasticsearch Index

3. Start Searching

twig
{% set results = craft.searchWithElastic.search(query) %}