Download the PHP package amrsoliman/laralastica without Composer

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

Laralastica Build Status Latest Stable Version Latest Unstable Version License

A laravel 5 package that adds the ability to search eloquent models using elasticsearch results, it also handles indexing and removing documents when you save or delete models.

Installation

This package requires at least PHP 5.4 and at present only supports Laravel 5.0.

To install through composer either run composer require michaeljennings/laralastica or add the package to you composer.json

Then add the laralastica service provider into your providers array in config/app.php.

The package also comes with a facade, to use it add it to your aliases array in config/app.php.

Config

Finally publish the package config using php artisan vendor:publish. Once the config has published you can edit the `config/laralastica.php' file to set your elasticsearch connection. To set the connection you can either pass the host and port to connect to, or alternatively you can pass a url to connect with.

There is also an empty types array. This allows you to bind an elasticsearch type to a model so that when you search elasticsearch it will return results belonging to that type as the specified model.

Usage

To get started using the package simply add the Searchable trait to the models you want to index and search.

Once you have added the trait it will use model events to watch when a model is saved, deleted or restored and will add or delete the elasticsearch document as appropriate.

Set Elasticsearch Type

To set the elasticsearch type for the model use the getSearchType method to return the name of the type. By default this will return the table name the model is using.

Set Elasticsearch Key To Index By

To set the value to index the elasticsearch documents by use the 'getSearchKey' method to return the key. By default this will return the primary key of the model.

Set the Attributes to Index

To set which attributes should be indexed for the model use the getIndexableAttributes method. The attributes must be returned as an array of key value pairs. By default all of the models attributes are indexed.

Type Cast Attributes

When you index attributes you may need to type cast the value, to do this use the getSearchDataTypes method. This must return an array with the key as the column being indexed and the value as the data type. The data types supported are:

Searching

To run a search use the search method. This uses a closure to search the elasticsearch type and then gets the results and adds a where in query from the results.

The first parameter for the search method is a Closure which gets passed an instance of the laralastica query builder.

The second paramater is the column for the where in query, this defaults to 'id'.

The third parameter is a key to group the elasticsearch results, the grouped results are then passed to the where in query. This also defaults 'id'.

You can also set whether the query must, should or must not match the value you are searching for.

You may also chain any Laravel query builder methods before or after searching.

Searching Without the Searchable Trait

It is also possible to use Laralastica without using the searchable trait. To do so you can either dependency inject the class via its contract or use the provided Facade.

To run a new query use the search method. This takes two parameters:

To search across multiple elasticsearch types simply pass an array of types as the first parameter.

Match Query

To run a match query call match on the query builder. This takes 4 parameters:

The two types of search you can run are phrase and phrase_prefix. The phrase match analyzes the text and creates a phrase query out of the analyzed text. The phrase prefix match is the same as phrase, except that it allows for prefix matches on the last term in the text.

For more information about the search types click here.

Multi Match Query

To run a multi match query use the multiMatch method on the query builder. This takes 6 parameters:

There are 5 different search types for the multi match: best_fields, most_fields, cross_fields, phrase and phrase_prefix.

best_fields finds documents which match any field, but uses the _score from the best field.

most_fields finds documents which match any field and combines the _score from each field.

cross_fields treats fields with the same analyzer as though they were one big field. Looks for each word in any field.

phrase runs a match_phrase query on each field and combines the _score from each field.

phrase_prefix runs a match_phrase_prefix query on each field and combines the _score from each field.

For more information about the search types click here.

Match All Query

To use a match all query use the matchAll method on the query builder.

Exists query

To run a exists query use the exists method. This takes 1 parameter:

For more information about the term query click here.

Common Query

To run a common query use the common method on the query builder. This takes 4 parameters:

For more information about the common query click here.

Range Query

To run a range query use the range method on the query builder. This takes 4 parameters:

To specify a range you pass an array which gt, gte, lt or lte as keys. So to get any values greater than 3 and less than 10 you would do the following.

To search for dates between the 1st January 1970 and 31st January 1970 you would do the following.

Regular Expression Query

To run a regular expression query use the regexp method. This takes 2 parameters:

For more information about the term query click here.

Term query

To run a term query use the term method. This takes 3 parameters:

For more information about the term query click here.

Terms Query

To run a terms query use the terms method. This takes 3 parameters:

For more information about the terms query click here.

Wildcard Query

To run a wildcard query use the wildcard method. This takes 2 parameters:

For more information about the wildcard query click here.


All versions of laralastica with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
ruflin/elastica Version 3.1.*
illuminate/database Version >=5.0
illuminate/events Version >=5.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 amrsoliman/laralastica contains the following files

Loading the files please wait ....