hungneox/ramen-elastic-query

Lumen/Laravel package for interacting with elasticsearch

dev-master 2018-01-21 18:43 UTC

This package is not auto-updated.

Last update: 2024-12-14 17:40:05 UTC


README

Build Status

Fluent Pseudo-SQL query builder for Elasticsearch built on top of Lumen Elasticsearch

Installation

Run the following command to install the package through Composer:

composer require hungneox/ramen-elastic-query

Add the following line to bootstrap/app.php:

$app->register(Neox\Ramen\Elastic\ElasticQueryServiceProvider::class);

Usage

Simple select

Object initiation or Facade both work

$builder = app(Builder::class);

$result = $builder
	->use('content') // collection
	->from('article') // type
	->find('TIYKtQX', '_id', ['id', 'title', 'description']);
            
$result = ES::use('content')
		->from('article')
		->find('TIYKtQX', '_id', ['id', 'title', 'description']);

Normal where clause

$result = $builder->select('id', 'description')
			->from('recipe')
			->where('_id', '=', $id)
			->get();

Fulltext match

$result = $builder
            ->use('content')
            ->select('id', 'title', 'description', 'featured')
            ->from('article')
            ->where('title', 'like', 'Auringonkukan')
            ->orderBy('featured', 'desc')
            ->get();

Deletion

ES::use('content')->from('article')->delete($id);

License

See LICENSE.