Download the PHP package rennokki/elasticscout without Composer

On this page you can find all versions of the php package rennokki/elasticscout. 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 elasticscout

ElasticScout - Elasticsearch Driver for Laravel Scout

CI Latest Stable Version Total Downloads Monthly Downloads codecov StyleCI License

ElasticScout is a Laravel Scout driver that interacts with any Elasticsearch server to bring the full-power of Full-Text Search in your models.

This package was shaped from Babenko Ivan's Elasticscout Driver repo.

🤝 Supporting

Renoki Co. on GitHub aims on bringing a lot of open source projects and helpful projects to the world. Developing and maintaining projects everyday is a harsh work and tho, we love it.

If you are using your application in your day-to-day job, on presentation demos, hobby projects or even school projects, spread some kind words about our work or sponsor our work. Kind words will touch our chakras and vibe, while the sponsorships will keep the open source projects alive.

ko-fi

🚀 Installation

Install the package using Composer CLI:

If your Laravel package does not support auto-discovery, add this to your config/app.php file:

Publish the config files:

If you wish to access directly the Elasticsearch Client, already set with the configuration of your own, you can do so by adding the facade to config/app.php:

Then you can access it like you normally would:

Configuring Scout

In your .env file, set yout SCOUT_DRIVER to elasticscout, alongside with Elasticsearch configuration:

AWS Elasticsearch Service

Amazon Elasticsearch Service works perfectly fine without any additional setup for VPC Clusters. However, it is a bit freaky about Public clusters because it requires IAM authentication.

You will first make sure that you have the right version of elasticsearch/elasticsearch package installed. For instance, for a 7.4 cluster, you should install elasticsearch/elasticsearch:"7.4.*", otherwise you will receive errors in your application.

To find the right package size, check the Elasticsearch's Version Matrix.

When requesting data from an AWS Elasticsearch cluster, ElasticScout makes sure your authentication will be passed to the further requests by attaching a handler. All you have to do is to enable the setup, by setting the SCOUT_ELASTICSCOUT_AWS_ENABLED env variable:

Please keep in mind: you do not need user & password for AWS Elasticsearch Service clusters.

📄 Indexes

Creating an index

In Elasticsearch, the Index is the equivalent of a table in MySQL, or a collection in MongoDB. You can create an index class using artisan:

You will have something like this in app/Indexes/PostIndex.php:

The key here is that you can set settings and a mapping for each index. You can find more on Elasticsearch's documentation website about mappings and settings.

Here's an example on creating a mapping for a field that is a geo-point datatype:

Here is an example on creating a new analyzer in the $settings variable for a whitespace tokenizer:

If you wish to change the name of the index, you can do so by overriding the $name variable:

Attach the index to a model

All the models that can be searched into should use the Rennokki\ElasticScout\Searchable trait and implement the Rennokki\ElasticScout\Index\HasElasticScoutIndex interface:

Additionally, the model should also specify the index class:

Publish the index to Elasticsearch

To publish the index to Elasticsearch, you should sync the index:

Now, each time your model creates,updates or deletes new records, they will be automatically synced to Elasticsearch.

In case you want to import already-existing data, please use the scout:import command that is described in the Scout documentation.

Syncing the index can also be done within your code:

🔍 Search Query

To query data into Elasticsearch, you may use the search() method:

In case you want just the number of the documents, you can do so:

🔺 Filter Query

ElasticScout allows you to create a custom query using built-in methods by going through the elasticsearch() method.

Must, Must not, Should, Filter

You can use Elasticsearch's must, must_not, should and filter keys directly in the builder. Keep in mind that you can chain as many as you want.

⚗️ Query Customizations

You can append data to body or query keys.

Wheres

Whens, Unless, Dynamic Wheres

If the dynamic where contains multiple words, they are split by snake_case:

Regex filters

Existence check

Since Elasticsearch has a NoSQL structure, you should be able to check if a field exists.

Geo-type searches

Working with Scopes

Elasticscout also works with scopes that are defined in the main model.

Query Caching

Query-by-query caching is available using rennokki/laravel-eloquent-query-cache. All you have to do is to check the repository on how to use it.

Basically, you can cache requests like so:

Elasticsearch Rules

A search rule is a class that can be used on multiple queries, helping you to define custom payload only once. This works only for the Search Query builder.

To create a rule, use the artisan command:

You will get something like this:

Query Payload

Within the buildQueryPayload(), you should define the query payload that will take place during the query.

For example, you can get started with some bool query. Details about the bool query you can find in the Elasticsearch documentation.

To apply by default on all search queries, define a getElasticScoutSearchRules() method in your model:

To apply the rule at the query level, you can call the ->addRule() method:

You can add multiple rules or set the rules to a specific value:

Highlight Payload

When building the highlight payload, you can pass the array to the buildHighlightPayload() method. More details on highlighting can be found in the Elasticsearch documentation.

To access the payload, you can use the $highlight attribute from the model (or from each model of the final collection).

In case you need to pass arguments to the rules, you can do so by adding your construct method.

🐛 Debugging queries

You can debug by explaining the query.

You can see how the payload looks like by calling getPayload().

🐛 Testing

🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

🎉 Credits


All versions of elasticscout with dependencies

PHP Build Version
Package Version
Requires elasticsearch/elasticsearch Version >=7.1
laravel/scout Version ^8.0
aws/aws-sdk-php Version ^3.132
rennokki/laravel-eloquent-query-cache Version ^1.3|^2.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 rennokki/elasticscout contains the following files

Loading the files please wait ....