• Stars
    star
    360
  • Rank 117,886 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ—ΊοΈ Next-gen Elasticsearch driver for Laravel Scout.

Explorer

Latest Version on Packagist

CI

Next-gen Elasticsearch driver for Laravel Scout with the power of Elasticsearch's queries.

Installation

Via Composer

composer require jeroen-g/explorer

You will need the configuration file to define your indexes:

php artisan vendor:publish --tag=explorer.config

Also do not forget to follow the installation instructions for Laravel Scout, and in your Laravel Scout config, set the driver to elastic.

Usage

Be sure to also have a look at the docs to see what is possible! There is also a demo app available that might be insightful.

Configuration

You may either define the mapping for you index in the config file:

return [
    'indexes' => [
        'posts_index' => [
            'properties' => [
                'id' => 'keyword',
                'title' => 'text',
            ],
        ]
    ]
];

Or you may define the model for the index, and the rest will be decided for you:

return [
    'indexes' => [
        \App\Models\Post::class
    ],
];

In the last case you may implement the Explored interface and overwrite the mapping with the mappableAs() function.

Essentially this means that it is up to you whether you like having it all together in the model, or separately in the config file.

Advanced queries

The documentation of Laravel Scout states that "more advanced "where" clauses are not currently supported". Only a simple check for ID is possible besides the standard fuzzy term search:

$posts = Post::search('lorem ipsum')->get();

Explorer expands your possibilities using query builders to write more complex queries.

For example, to get all posts that:

  • are published
  • have "lorem" somewhere in the document
  • have "ipsum" in the title
  • maybe have a tag "featured", if so boost its score by 2

You could execute this search query:

$posts = Post::search('lorem')
    ->must(new Matching('title', 'ipsum'))
    ->should(new Terms('tags', ['featured'], 2))
    ->filter(new Term('published', true))
    ->get();

Commands

Be sure you have configured your indexes first in config/explorer.php and run the Scout commands.

Searching indexes

php artisan elastic:search "App\Models\Post" lorem

Changelog

Please see the changelog for more information on what has changed recently.

Credits

License

MIT. Please see the license file for more information.

More Repositories

1

laravel-photo-gallery

A photo gallery for Laravel
PHP
40
star
2

packager-skeleton

Skeleton for creating Laravel packages with Laravel Packager
PHP
26
star
3

Flickr

Modern PHP package to make Flickr API calls. Ships with Laravel implementation.
PHP
25
star
4

GuestPass

Flickr-like Guest Pass system for Laravel
PHP
21
star
5

autowire

πŸ”Œ Autowire and configure using PHP 8 Attributes in Laravel.
PHP
19
star
6

Crosswind

Crosswind is an Tailwind CSS addon for Laravel apps.
CSS
19
star
7

activity-logger

A simple activity logger for Laravel.
PHP
10
star
8

Hummingbird

Validate your DOM to be SEO-proof.
PHP
10
star
9

laravel-pages

Simple pages package for Laravel
PHP
9
star
10

explorer-demo

The demo app for https://github.com/Jeroen-G/Explorer
PHP
8
star
11

alpine-artisan

A set of lightweight Docker images created with Laravel in mind, but work just as fine for other applications.
Dockerfile
7
star
12

laravel-auth

A simple extension of laravel's authentication (in beta, L4). DEPRECATED
PHP
6
star
13

cronlog

Allows you to log cron jobs to where *you* want it.
PHP
6
star
14

Blade-macro

Create small, file-specific, macros in Blade like Twig has.
PHP
5
star
15

laravel-builder

Build rapidly classes based on stubs.
PHP
5
star
16

statinator

Framework agnostic PHP state machines and state charts.
PHP
4
star
17

testassist

Helpers for testing with Laravel and PHPUnit
PHP
1
star
18

generators

My personal laravel generator commands package.
PHP
1
star
19

expo-template-kickstart

TypeScript
1
star
20

Laravel-Extension-Pack

A collection of VS Code extensions useful for Laravel development
1
star
21

Ontology

Explain your domain with PHP Attributes
PHP
1
star
22

expo-router-repro

JavaScript
1
star
23

ontology-publish

Present your documentation generated with Ontology
JavaScript
1
star
24

Bonfire

Boilerplate for new projects.
Makefile
1
star