Download the PHP package la-haute-societe/craft-elasticsearch without Composer

On this page you can find all versions of the php package la-haute-societe/craft-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 craft-elasticsearch

Elasticsearch plugin for Craft CMS

Bring the power of Elasticsearch to your Craft CMS projects.

Requirements

This plugin works with Craft CMS 3 or 4.

In order to index data, you will need an Elasticsearch 6.0 (or later) instance, with the Ingest attachment processor plugin activated.

Installation

The easy way

Just install the plugin from the Craft Plugin Store.

Using Composer

Elasticsearch plugin Overview

Elasticsearch plugin will automatically index each entry and Craft Commerce product (if installed) on your site(s).

It will figure out the best Elasticsearch mapping for you based on your site(s)' language.

Supported languages

Craft language Elastic analyzer Notes
ar arabic
hy armenian
eu basque
bn bengali
pt-BR brazilian
bg bulgarian
ca catalan
zh cjk
ja cjk
ko cjk
cs czech
da danish
nl dutch
en english
fi finnish
fr french
gl galician
de german
el greek
hi hindi
hu hungarian
id indonesian
ga irish
it italian
lv latvian
lt lithuanian
nb norwegian
fa persian
pt portuguese
ro romanian
ru russian
uk ukrainian analysis-ukrainian plugin needed
es spanish
pl polish analysis-stempel plugin needed
sv swedish
tr turkish
th thai

Configuring the Elasticsearch plugin

You can configure the Elasticsearch plugin from the Craft Control Panel (some settings only), of from the config/elasticsearch.php file in your Craft installation (all settings). If a setting is defined both in the CP and in the configuration file, the latter takes precedence.

The src/config.php, file is a configuration template to be copied to config/elasticsearch.php.

💡 If you currently don't have an Elasticsearch server handy, here's how you can set one up.

In both the configuration file and the CP

elasticsearchEndpoint

Type: string

The Elasticsearch instance endpoint URL (with protocol, host and port). Ignored if elasticsearchComponentConfig is set.

isAuthEnabled

Type: bool

A boolean indicating whether authentication is required on the Elasticsearch instance. Ignored if elasticsearchComponentConfig is set.

username

Type: string

The username used to authenticate on the Elasticsearch instance if it's protected by X-Pack Security. Ignored if isAuthEnabled is set to false or elasticsearchComponentConfig is set.

password

Type: string

The password used to authenticate on the Elasticsearch instance if it's protected by X-Pack Security. Ignored if isAuthEnabled is set to false or elasticsearchComponentConfig is set.

indexNamePrefix

Type: string

Index name prefix used to avoid index name collision when using a single Elasticsearch instance with several Craft instances.
Up to 5 characters, all lowercase.

highlight

Type: array

The elasticsearch configuration used to highlight query results. Only pre_tags and post_tags are configurable in the CP, advanced config must be done in the file. For more options, refer to the elasticsearch documentation.

blacklistedEntryTypes

Type: string[]

An array of entry type handles. Entries of those types won't be indexed.

blacklistedAssetVolumes

Type: string[]

An array of asset volume handles. Assets in those volumes won't be indexed.

Only in the configuration file

contentExtractorCallback

Type: callable

A callback function (function(string $entryContent): string) used to extract the content to be indexed from the full HTML source of the entry's page.

The default is to extract the HTML code between those 2 comments: <!-- BEGIN elasticsearch indexed content --> and <!-- END elasticsearch indexed content -->.

elementContentCallback

Type: callable

A callback function (function (\craft\base\ElementInterface $element): string) used to get the HTML content for the given element to index.

Note:

  • If this parameter is not set or null, the default Guzzle client implementation will be used to get the HTML content of the element. If set, you will have to handle that part yourself.
  • Content should be returned as HTML content in order to be correctly indexed.

resultFormatterCallback

Type: callable

A callback function (function (array $formattedResult, $result): array) used to prepare and format the Elasticsearch result object in order to be used by the results twig view.

elasticsearchComponentConfig

Type: array

An associative array passed to the yii2-elasticsearch component Connection class constructor. All public properties of the yii2-elasticsearch component Connection class can be set. If this is set, the elasticsearchEndpoint, username, password and isAuthEnabled settings will be ignored.

extraFields

Type: array

An associative array allowing to declare additional fields to be indexed along with the defaults ones. See Index additional data for more details.

Indexable content

By default, the content indexed in each entry is between the <!-- BEGIN elasticsearch indexed content --> and <!-- END elasticsearch indexed content --> HTML comments in the source of the entry page.

If you're using semantic HTML in your templates, then putting your <main> or <article> element between those comments should be ideal.

If you need more control over what is indexed, you'll have to set up a custom contentExtractorCallback.

Running a search

The search feature can be used from a frontend template file by calling the craft.elasticsearch.search('Something to search') variable. For instance, in a template search/index.twig:

Each entry consists of the following attributes:

Notes:

  • To add additional attributes, see Index additional data for more details.
  • To customize the Elasticsearch query, see More complex way to get even more control

Auto indexing

The plugin automatically indexes entries and Craft Commerce products (created, updated or removed), as long as they're not in a blacklisted entry types, or disabled.

All entries are reindexed (in the background) when plugin settings are saved.

Elasticsearch plugin utilities

If your Elasticsearch index becomes out of sync with your sites contents, you can go to Utilities → Elasticsearch then click the Reindex all button.

Elasticsearch plugin console commands

The plugin provides an extension to the Craft console command that lets you reindex all entries or recreate empty indexes.

Recreate empty indexes

Remove index & create an empty one for all sites

`

Reindex all sites

`

Notes:

  • The command will probably fail in case you don't affect a specific domain to a given site, for instance, avoid to use @web as a base URL.

Indexing of additional data

Simple way using the configuration file

To easily index additional data (elasticsearch fields), you can declare them using the extraFields parameter in the plugin configuration file.

Each field should be declared by using associative array with keys representing fields names and value as an associative array to configure the field behavior:

For example, to declare a color field in the configuration file, one could do:

More complex way to get even more control

You can get even more control over your additional data by listening to the following events in some project module:

Tips

Enable fuzziness

As of the other search query parameters, you can set fuzziness by altering default search query as follow:

Troubleshooting

Elasticsearch is a trademark of Elasticsearch BV, registered in the U.S. and in other countries.


All versions of craft-elasticsearch with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^3.5.0
yiisoft/yii2-elasticsearch Version ^2.1.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 la-haute-societe/craft-elasticsearch contains the following files

Loading the files please wait ....