All Projects → babenkoivan → Elastic Scout Driver

babenkoivan / Elastic Scout Driver

Licence: mit
Elasticsearch driver for Laravel Scout

Projects that are alternatives of or similar to Elastic Scout Driver

Elastic Scout Driver Plus
Extension for Elastic Scout Driver
Stars: ✭ 90 (+21.62%)
Mutual labels:  elastic, elasticsearch, laravel, driver
Scout Elasticsearch Driver
This package offers advanced functionality for searching and filtering data in Elasticsearch.
Stars: ✭ 1,047 (+1314.86%)
Mutual labels:  elastic, elasticsearch, laravel
Laravel Elasticsearch
An easy way to use the official Elastic Search client in your Laravel applications.
Stars: ✭ 717 (+868.92%)
Mutual labels:  elasticsearch, laravel
Adldap2 Laravel
LDAP Authentication & Management for Laravel
Stars: ✭ 825 (+1014.86%)
Mutual labels:  laravel, driver
Laravel Scout Elastic
Elastic Driver for Laravel Scout
Stars: ✭ 886 (+1097.3%)
Mutual labels:  elasticsearch, laravel
Graphql Compose Elasticsearch
Hide Elastic Search REST API behind GraphQL.
Stars: ✭ 498 (+572.97%)
Mutual labels:  elastic, elasticsearch
Laravel Shopify
A full-featured Laravel package for aiding in Shopify App development
Stars: ✭ 634 (+756.76%)
Mutual labels:  laravel, driver
Php Es Mapper
An elasticsearch simple mapping ORM for php
Stars: ✭ 25 (-66.22%)
Mutual labels:  elastic, elasticsearch
Laravel Scout Elastic Demo
笑来搜原型 Laravel Scout & ElasticSearch ik
Stars: ✭ 403 (+444.59%)
Mutual labels:  elasticsearch, laravel
Laravel Dropbox Driver
A storage extension for Dropbox.
Stars: ✭ 42 (-43.24%)
Mutual labels:  laravel, driver
Kbframe
一款基于Laravel框架开发的现代化二次开发框架,是高性能,高效率,高质量的企业级开发框架,具有驱动领域,敏捷开发,轻易上手,高内聚低耦合,开箱即用等特点。
Stars: ✭ 47 (-36.49%)
Mutual labels:  elasticsearch, laravel
Plastic
Plastic is an Elasticsearch ODM and mapper for Laravel. It renders the developer experience more enjoyable while using Elasticsearch, by providing a fluent syntax for mapping, querying, and storing eloquent models.
Stars: ✭ 494 (+567.57%)
Mutual labels:  elasticsearch, laravel
Laravel Scout Elasticsearch
Search among multiple models with ElasticSearch and Laravel Scout
Stars: ✭ 423 (+471.62%)
Mutual labels:  elasticsearch, laravel
Elasticsql
convert sql to elasticsearch DSL in golang(go)
Stars: ✭ 687 (+828.38%)
Mutual labels:  elastic, elasticsearch
Pfelk
pfSense/OPNsense + ELK
Stars: ✭ 417 (+463.51%)
Mutual labels:  elastic, elasticsearch
Laravel Docker Elasticsearch
This is a simple repo for practicing elasticsearch with laravel and docker.
Stars: ✭ 18 (-75.68%)
Mutual labels:  elasticsearch, laravel
Elasticsearch Cli
Command line interface for ElasticSearch
Stars: ✭ 70 (-5.41%)
Mutual labels:  elastic, elasticsearch
Candy Api
GetCandy E-Commerce API
Stars: ✭ 339 (+358.11%)
Mutual labels:  elasticsearch, laravel
Elasticsearch
The missing elasticsearch ORM for Laravel, Lumen and Native php applications
Stars: ✭ 375 (+406.76%)
Mutual labels:  elasticsearch, laravel
Elastic data
Elasticsearch datasets ready for bulk loading
Stars: ✭ 30 (-59.46%)
Mutual labels:  elastic, elasticsearch

Buy Me A Coffee


Elasticsearch driver for Laravel Scout.

Contents

Compatibility

The current version of Elastic Scout Driver has been tested with the following configuration:

  • PHP 7.2-8.0
  • Elasticsearch 7.0-7.10
  • Laravel 6.x-8.x
  • Laravel Scout 7.x-8.x

Installation

The library can be installed via Composer:

composer require babenkoivan/elastic-scout-driver

Note, that this library is just a driver for Laravel Scout, don't forget to install it beforehand:

composer require laravel/scout

When Scout is installed publish its configuration and change the driver option in the config/scout.php file to elastic:

php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"

If you want to use Elastic Scout Driver with Lumen framework check this guide.

Configuration

Elastic Scout Driver uses babenkoivan/elastic-client as a dependency. If you want to change the default client settings (and I'm pretty sure you do), then you need to create the configuration file first:

php artisan vendor:publish --provider="ElasticClient\ServiceProvider"

You can change Elasticsearch host and the other client settings in the config/elastic.client.php file. Please refer to babenkoivan/elastic-client for more details.

Elastic Scout Driver itself has only one configuration option at the moment - refresh_documents. If it's set to true (false by default) documents are indexed immediately, which might be handy for testing.

You can configure refresh_documents in the config/elastic.scout_driver.php file after publishing it with the following command:

php artisan vendor:publish --provider="ElasticScoutDriver\ServiceProvider"

At last, do not forget, that with Scout you can configure the searchable data, the model id and the index name. Check the official Scout documentation for more details.

Note, that the _id field can't be part of the searchable data, so make sure the field is excluded or renamed in the toSearchableArray method in case you are using MongoDB as the database.

Basic usage

Elastic driver uses Elasticsearch query string wrapped in a bool query under the hood. It means that you can use mini-language syntax when searching a model:

$orders = App\Order::search('title:(Star OR Trek)')->get();

When the query string is omitted, the match all query is used:

$orders = App\Order::search()->where('user_id', 1)->get();

Please refer to the official Laravel Scout documentation for more details and usage examples.

Advanced Search

In case the basic search doesn't cover your project needs check Elastic Scout Driver Plus, which extends standard Scout search capabilities by introducing advanced query builders. These builders give you possibility to use compound queries, custom filters and sorting, highlights and more.

Migrations

If you are looking for a way to control Elasticsearch index schema programmatically check Elastic Migrations. Elastic Migrations allow you to modify application's index schema and share it across multiple environments with the same ease, that gives you Laravel database migrations.

Pitfalls

There are few things, which are slightly different from other Scout drivers:

  • As you probably know, Scout only indexes fields, which are returned by the toSearchableArray method. Elastic driver indexes a model even when toSearchableArray returns an empty array. You can change this behaviour by overwriting the shouldBeSearchable method of your model:
public function shouldBeSearchable()
{
    return count($this->toSearchableArray()) > 0;
}
  • Raw search returns an instance of SearchResponse class (see Elastic Adapter):
$searchResponse = App\Order::search('Star Trek')->raw();
  • To be compatible with other drivers and to not expose internal implementation of the engine, Elastic driver ignores callback parameter of the search method:
App\Order::search('Star Trek', function () {
    // this will not be triggered
})->get()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].