Download the PHP package ccennis/larelastic without Composer
On this page you can find all versions of the php package ccennis/larelastic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download ccennis/larelastic
More information about ccennis/larelastic
Files in ccennis/larelastic
Download ccennis/larelastic
More information about ccennis/larelastic
Files in ccennis/larelastic
Vendor ccennis
Package larelastic
Short Description Generic Wrapper for elasticsearch and indexing
License
Package larelastic
Short Description Generic Wrapper for elasticsearch and indexing
License
Please rate this library. Is it a good library?
Informations about the package larelastic
larelastic
An indexing and querying package to create, maintain and search an elastic instance with Laravel Scout as backbone.
Contents
- Installation
- Indexes
- Create and Maintain Index
- Migrating data
- Updating index
- Drop index
- Additional Configuration Options
- Indexes
- Usage and Examples
- Searching
- Where Example
- orWhere Example
- Multimatch Example
- Pagination Example
- Sorting Example
- GeoSorting Example
- Aggs Example
- Multimatch Example
- Searching
Installation
Laravel
Add the Third Party Service Providers in config/app.php
Add the Third Party Aliases in config/app.php
Get Config Files
Add the following variables to your .env file
``
Indexing
(for a completely new installation -- skip ahead past 3rd step if index exists)
Since this package relies on the existence of models and index configurators to create, search and maintain indices, you must run the below commands to generate and set up the appropriate objects.
1.) create an indexConfigurator model (in this example, "Tattoo"):
2.) create your searchable Model:
3.) create your Elastic index using model with full path:
## Indexing
4.) add data to your index
### Migrating to new Index
This process creates a new index, imports all data from previous to this index, and then links the old index to this new one via an alias
### Update a mapping:
### Update index:
### Drop index:
### Additional Configuration Options:
In your designated model, you may want to make use of the method:
This will enable you to fine tune the actual query that is sent to elastic if you need to eager load or specify relationships.
## Usage and Examples
Where/OrWhere queries make use of the [bool](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html) methods (`must`, `must_not`, and `should`). Syntax is meant to be eloquent-like, but must use the `search` trait to differentiate it from actual Eloquent.
### Valid Operators
Operator | Function | Usage
---------| ---------|--------
= | equals | ->where('col', '=', 'value')
->where('col', 'value') <> | not equals | ->where('col', '<>', 'value') in | in field array | ->where('col', 'in', ['value']) begins_with| search phrase beginning matched to search | ->where('col', 'begins_with', 'value') ends_with | search phrase ending matched to search | ->where('col', 'ends_with', 'value') contains | search phrase found in field | ->where('col', 'contains', 'value') gte | >= | ->where('col', 'gte', 'value') lte | <= | ->where('col', 'lte', 'value') gt | > | ->where('col', 'gt', 'value') lt | < | ->where('col', 'lt', 'value') between | date found between two dates | ->where('col', 'between', ['value1', 'value2']) exists | the value is not null and is found in index | ->where('col', 'exists') #### Sample `Where` query Both of the above queries are valid. Default operator is '=' unless provided. #### Sample `Or Where` query takes two arrays, makes use of the `should` bool operator from Elastic. Evaluates to "find this OR that". Closure, makes use of multiple groupings under `should` bool operator from Elastic. Evaluates to "find (this AND that) OR (this and that)". #### Sample `Multimatch` query This makes use of the [multimatch](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) elastic function, takes an array of fields. Default search type is [phrase prefix](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-phrase), but accepts an argument to override, such as [best_fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-best-fields): #### Pagination Pagination functions much the same as in eloquent. It will wrap your response in the Paginator Length Aware metadata fields: #### Sorting Simple Sorting: Sorting defaults to asc and can be stacked for multiple sorts. If you need to specify a field_type for the sort field (i.e. 'keyword' or 'raw') you can include it as a param: The above may be necessary in the event you are already querying a nested object and want to ensure the datatype is listed separately. #### Geosorting Sorting by distance based on latitude and longitude. Sample query in Elastic: In order to use this in the package, you can use the following syntax: There is also support to return the distance query as raw syntax, which can be used in the Top Level OR statement. An example: Valid fields to pass in the data array are above in the elastic query. Valid arguments for unit include: mi (miles), in (inches), yd (yards), km (kilometers), cm (centimeters), mm (millimeters). There are two distance calculation modes: arc (the default), and plane. The arc calculation is the most accurate. initial support for aggs takes a column name and creates buckets to count all matches. result set will be under an "aggs" object, like so:
->where('col', 'value') <> | not equals | ->where('col', '<>', 'value') in | in field array | ->where('col', 'in', ['value']) begins_with| search phrase beginning matched to search | ->where('col', 'begins_with', 'value') ends_with | search phrase ending matched to search | ->where('col', 'ends_with', 'value') contains | search phrase found in field | ->where('col', 'contains', 'value') gte | >= | ->where('col', 'gte', 'value') lte | <= | ->where('col', 'lte', 'value') gt | > | ->where('col', 'gt', 'value') lt | < | ->where('col', 'lt', 'value') between | date found between two dates | ->where('col', 'between', ['value1', 'value2']) exists | the value is not null and is found in index | ->where('col', 'exists') #### Sample `Where` query Both of the above queries are valid. Default operator is '=' unless provided. #### Sample `Or Where` query takes two arrays, makes use of the `should` bool operator from Elastic. Evaluates to "find this OR that". Closure, makes use of multiple groupings under `should` bool operator from Elastic. Evaluates to "find (this AND that) OR (this and that)". #### Sample `Multimatch` query This makes use of the [multimatch](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) elastic function, takes an array of fields. Default search type is [phrase prefix](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-phrase), but accepts an argument to override, such as [best_fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-best-fields): #### Pagination Pagination functions much the same as in eloquent. It will wrap your response in the Paginator Length Aware metadata fields: #### Sorting Simple Sorting: Sorting defaults to asc and can be stacked for multiple sorts. If you need to specify a field_type for the sort field (i.e. 'keyword' or 'raw') you can include it as a param: The above may be necessary in the event you are already querying a nested object and want to ensure the datatype is listed separately. #### Geosorting Sorting by distance based on latitude and longitude. Sample query in Elastic: In order to use this in the package, you can use the following syntax: There is also support to return the distance query as raw syntax, which can be used in the Top Level OR statement. An example: Valid fields to pass in the data array are above in the elastic query. Valid arguments for unit include: mi (miles), in (inches), yd (yards), km (kilometers), cm (centimeters), mm (millimeters). There are two distance calculation modes: arc (the default), and plane. The arc calculation is the most accurate. initial support for aggs takes a column name and creates buckets to count all matches. result set will be under an "aggs" object, like so:
All versions of larelastic with dependencies
PHP Build Version
Package Version
The package ccennis/larelastic contains the following files
Loading the files please wait ....