Giter Club home page Giter Club logo

laravel-elasticsearch's Introduction

Elasticsearch for Laravel

This is a Laravel (4+) Service Provider for the official Elasticsearch low-level client: http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/index.html

Version Matrix

Since there are breaking changes in Elasticsearch 1.0, your version of Elasticsearch must match the version of this library, which matches the version of the Elasticsearch low-level client. If you are using a version older than 1.0, you must install the 0.4 laravel-elasticsearch branch. Otherwise, use the 1.0 branch.

The master branch will always track the latest version.

Elasticsearch Version laravel-elasticsearch branch
>= 1.0 1.0
<= 0.90.* 0.4

Support for v1.1.x of the Elasticsearch client has been added in v1.1 of laravel-elasticsearch. We'll try to be consistent with this convention going forward.

Usage

  1. Run composer require shift31/laravel-elasticsearch

  2. Create app/config/elasticsearch.php, modifying the following contents accordingly:

<?php

use Monolog\Logger;

return array(
    'hosts' => array(
                    'your.elasticsearch.server:9200'
                    ),
    'logPath' => 'path/to/your/elasticsearch/log',
    'logLevel' => Logger::INFO
);

The keys of this array should be named according the parameters supported by Elasticsearch\Client.

  1. In the 'providers' array in app/config/app.php, if you are using Laravel 4, add 'Shift31\LaravelElasticsearch\LaravelElasticsearchServiceProvider'. If you are using Laravel 5, add 'Shift31\LaravelElasticsearch\ElasticsearchServiceProvider'. The ServiceProvider will enable the 'Es' facade for you.

  2. Use the Es facade to access any method from the Elasticsearch\Client class, for example:

$searchParams['index'] = 'your_index';
$searchParams['size'] = 50;
$searchParams['body']['query']['query_string']['query'] = 'foofield:barstring';

$result = Es::search($searchParams);

Default Configuration

If you return an empty array in the config file:

'hosts' defaults to localhost:9200

'logPath' defaults to storage_path() . '/logs/elasticsearch-' . php_sapi_name() . '.log'

'logLevel' defaults to Logger::INFO

laravel-elasticsearch's People

Contributors

bgetsug avatar samuelcasas avatar

Watchers

James Cloos avatar Mukete  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.