Download the PHP package thehome/statamic-elasticsearch without Composer

On this page you can find all versions of the php package thehome/statamic-elasticsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package statamic-elasticsearch

Statamic 3.0+ Latest Version on Packagist

Elasticsearch driver for Statamic

This addon add's a Elasticsearch driver to Statamics builtin search system ( docs ).

Setup index

Indexes are configured in config/statamic/search.php and uses the standard Statamic index configuration. There's a few extra nice configuration options.

Here's an entry in indexes for the pages collection:

'public' => [
  'driver' => 'elasticsearch',
  'searchables' => 'collection:pages',
  'fields' => ['title', 'description', 'content'],
],

Here's an example entry in the drivers section defining the connection properties for your Elasticsearch server.

'elasticsearch' => [
    'hosts' => [[
       'scheme' => env('ELASTICSEARCH_SCHEME', 'http'),
       'host' => env('ELASTICSEARCH_HOST', '127.0.0.1'),
       'port' => env('ELASTICSEARCH_PORT', 9200),
    ]]
],

Content transformation

Statamic supports transformers for the index data, but the current implementation is not compatible with how Laravel serializes the configuration when running php artisan optimize. Therefore this driver has it's own system that can be configured like this:

'public' => [
  ...
  'transforms' => ['content' => 'bardToText'],
],

Available transformers

Analyzers

Elasticsearch supports different text analyzers for indexing. The analyzer determines how tokenization, stop-words and stemming is handled. You can set the default analyzer used (for all fields) like this:

'public' => [
  'driver' => 'elasticsearch',
  'searchables' => 'collection:pages',
  'fields' => ['title', 'description', 'content'],
  'analyzer' => 'danish'
],

If not set, the standard analyzer is used. See list of available language analyzers here.

Field boost

You can boost individual fields by defining a boost value.

'boost' => [
    'title' => '2',
    'keywords' => '2'
]

Updating indexes

Whenever you save an item in the Control Panel it will automatically update any appropriate indexes as this is extending the Statamic search. As expected you can update the index via command line.

php please search:update public

Verify indexed data

You can verify that your elaticsearch index looks correct with:

curl 127.0.0.1:9200/_cat/indices/public?v

Or make queries directly with:

curl 127.0.0.1:9200/public/_search?q=test | jq

Templating

You can use the default Statamic search tag like usual:

{{ search:results index="public"}}
    {{ if no_results }}
        <h2>No results.</h2>
    {{ else }}
        <a href="{{ url }}">
            <div>{{ title }}</div>
            <p>{{ description | truncate:180 }}</p>
        </a>
    {{ /if }}
{{ /search:results }}

Livewire componenent with pagination

The included Livewire component supports pagination using Elasticsearch for the pagination. This requires that the fields status are indexed so add them to the config:

'public' => [
  ....
  'fields' => [ ... 'status'],
],

If you have multiple sites and wan't the search page to only return results from a specific site then you must add the site field to the index. The site field is an object so it must be transformed with the handle transformer.

'public' => [
  ....
  'fields' => [ ... 'status', 'site'],
  'transforms' => ['site' => 'handle'],
],     

Then you need to have Livewire support for your antlers templates. The easy way is to install Jonas's addon :

composer require jonassiewertsen/statamic-livewire

Then make your search antlers template including:

{{ livewire:styles }}
{{ livewire:elasticsearch.search index="public" size="10"}}
{{ livewire:scripts }}  

The template can be overridden by publishing it:

php artisan vendor:publish --tag=elasticsearch-views

Planned features


All versions of statamic-elasticsearch with dependencies

PHP Build Version
Package Version
Requires elasticsearch/elasticsearch Version ^7.0
php Version ^8.0
laravel/framework Version ^7.0 || ^8.0 || ^9.0 || ^10.0
statamic/cms Version ^3.4 || ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package thehome/statamic-elasticsearch contains the following files

Loading the files please wait ....