Download the PHP package greensight/laravel-elastic-query without Composer

On this page you can find all versions of the php package greensight/laravel-elastic-query. 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 laravel-elastic-query

Laravel Elastic Query

Deprecated, use https://github.com/ensi-platform/laravel-telemetry instead

Working with Elasticsearch in an Eloquent-like fashion.

Installation

You can install the package via composer:

  1. composer require greensight/laravel-elastic-query
  2. Set ELASTICSEARCH_HOSTS in your .env file. , can be used as a delimeter.

Basic usage

Let's create and index class. It's someting like Eloquent model.

You should set a unique in document attribute name in $tiebreaker. It is used as an additional sort in search_after

Now we can get some documents

Filtering

nested_field must have nested type. Subqueries cannot use fields of main document only subdocument.

Sorting

Second attribute is a direction. It supports asc and desc values. Defaults to asc.
Third attribute - sorting type. List of supporting types: min, max, avg, sum, median. Defaults to min.

There are also dedicated sort methods for each sort type.

Pagination

Offset Pagination

Offset pagination returns total documents count as total and current position as size/offset.

Cursor pagination

current, next, previous is returned in this case instead of total, size and offset. You can check Laravel docs for more info about cursor pagination.

Aggregation

Aggregaction queries can be created like this

Type of $aggs->price is MinMax. Type of $aggs->codes is BucketCollection. Aggregate names must be unique for whole query.

Aggregate types

Get all variants of attribute values:

Get min and max attribute values. E.g for date:

Aggregation plays nice with nested documents.

There is also a special virtual composite aggregate on the root level. You can set special conditions using it.

Query Log

Just like Eloquent ElasticQuery has its own query log, but you need to enable it manually Each message contains indexName, query and timestamp

Contributing

Please see CONTRIBUTING for details.

Testing

  1. composer install
  2. npm i
  3. Start Elasticsearch in your preferred way.
  4. Copy phpunit.xml.dist to phpunit.xml and set correct env variables there
  5. composer test

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-elastic-query with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
elasticsearch/elasticsearch Version ^7.13
illuminate/support Version ^8.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 greensight/laravel-elastic-query contains the following files

Loading the files please wait ....