Download the PHP package nexucis/es-index-helper without Composer

On this page you can find all versions of the php package nexucis/es-index-helper. 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?
nexucis/es-index-helper
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package es-index-helper

Elasticsearch Index Helper for php

CircleCI codecov Latest Stable Version Total Downloads

  1. Overview
  2. Installation
  3. Quickstart
  4. Contributions
  5. Development
  6. License

Overview

This project provides an index Helper in order to help you to manage your ES Indices with no downtime. This helper implements the philosophy described in the official documentation which can be summarized in a few words : use alias instead of index directly

Versioning

This project uses the following version rules:

Where :

Supported Version

Elasticsearch Version Support Branch
>= 7.0 master
>= 6.0, < 7.0 support/6.0
>= 5.0, < 6.0 support/5.0
>= 2.0, < 5.0 support/2.0

Installation

The recommended method to install this library is through Composer.

where X.Y is the version which fit your need.

Or you can just use the composer command to modify your composer.json and update your dependencies :

To configure the elasticsearch client, you can read the associated documentation

Quickstart

We encourage users to take a look at the interface in order to have an idea of all available methods. The following description is not exhaustive, so you will miss some method if you don't cast a glance at the code

Index Operations

Create an index

It all begins with an index creation :

As you can see, we pass an alias name and not and index name through the helper. With the Helper, you will see everything through an alias and not the index directly.

The method below will create an index with the name myindex and with the suffix _v1, and put an alias with the name myindex.

If you request ElasticSearch directly (with Sense for example), you could see something like this :

Delete an index

As we say, with this helper, you will see everything through an alias. So if you want to delete and index, just pass the alias like this :

And if you perform the previous HTTP request, you will see that there is nothing left. The alias AND the index has been removed.

Mappings Operation

This helper proves his existence when you want to change your mapping dynamically and you still want full access to your data.

So to make this things possible we need to:

  1. create a second index like myindex_v2
  2. copy the settings from myindex_v1 to myindex_v2
  3. put the new mapping in myindex_v2
  4. copy all documents from myindex_v1 to myIndex_v2.
  5. remove the old index myindex_v1 and put the alias myindex in the new one

It takes a lot of steps and verifications to check the update is done successfully. That's why this Helper comes here with the following simplify method :

You just need to provide the alias name and the new mapping and that's it.

:warning: With an index with many documents, the update can take a lot of time. That's why it's better:

:warning: Elasticsearch has started to remove the document type in the mapping. Following the recommendation, the method updateMappings has a new parameter $includeTypeName which allows to support the old mapping format

By default, the method updateMappings will consider the old mapping format which is for example :

If you want to move to the new format, you have to remove the type in the mapping and set to false the parameter $includeTypeName

Please be aware that the parameter $includeTypeName will be removed in the next major version

Settings Operation

Indices settings can be updated the same way as mapping using the updateSettings method:

Document Operations

Some document operations are also available with this helper. For example, you can add a document and retrieve it:

Contributions

Any contribution or suggestion would be really appreciated. Feel free to use the Issue section or to send a pull request.

Development

All following tools are running by circleci, so in order to help you to improve your code and make easier your life, here it is how you can launch the tools with the correct parameter.

Run unit test

If you want to launch the unit test, you need to have a local elasticsearch instance which must be accessible through the url http://localhost:9200. A simply way to launch it, is to start the corresponding container :

Once ElasticSearch is up, you can run the following command :

Run PHP_CodeSniffer

This tool will check if the code respects some coding rules. In this project, we just respect for the moment the PSR-2 coding rules.

To launch it, run the following command :

If you are interesting by this tool, you can learn about it here

Run PHPStan analyzer

This tool wiil find some errors in the code without running it.

To launch it, run the following command :

If you are interesting by this tool, you can learn about it here

Encoding Analyzer and EOL analyzer

The continuous integration analyze encoding and eol of php files and some others.

To perform this analyze, it uses the docker images nexucis/ci-checkfiles (available on docker hub.

If you are interesting by this tool, you can learn about it on the github repository

License

MIT


All versions of es-index-helper with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1 | ^8.0
elasticsearch/elasticsearch Version ^7.0.1
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 nexucis/es-index-helper contains the following files

Loading the files please wait ....