Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Explorer Laravel Package

jeroen-g/explorer

Laravel-friendly wrapper for Explorer, a lightweight full-text search engine. Index and search your Eloquent models with simple configuration, fast queries, and flexible ranking/filters. Ideal for adding on-site search without running Elasticsearch or Algolia.

View on GitHub
Deep Wiki
Context7

Quickstart

Elasticsearch is "a distributed, open source search and analytics engine for all types of data" using REST and JSON. The key concepts being are the index (a collection of documents), full-text searches and data ingestion (the processing of raw data). Kibana is the interface to visualise and navigate through your elasticsearch indexes.

A very good way to get started with Elasticsearch is by creating a docker container and connecting it to your Laravel application. You could use Tighten's Takeout for the Elasticsearch container, however it comes without Kibana. To get started with Elasticsearch and Kibana, create a docker-compose.yml file and paste this configuration from Elastic's documentation. After that, run docker-compose up -d and you will have an elasticsearch instance running at localhost:9200 and a Kibana instance at localhost:5601

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic

  kib01:
    image: docker.elastic.co/kibana/kibana:7.9.3
    container_name: kib01
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_URL: http://es01:9200
      ELASTICSEARCH_HOSTS: http://es01:9200
    networks:
      - elastic

volumes:
  data01:
    driver: local

networks:
  elastic:
    driver: bridge

The thing you should do next, if you haven't already, is follow the Laravel Scout installation and configuration. The only point where you should diverge from the docs is the driver for scout (in config/scout.php):

'driver' => 'elastic',

After that, you can define your first index in config/explorer.php:

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

Upon saving the file, run php artisan scout:import "App\Models\Post" to add your posts as documents to the index. This of course assumes that you have a Post model (with an ID and title attribute) and a couple of entries of them in your database. As mentioned before, Laravel Scout also has a few requirements explained in its documentation for your models.

To query your posts, use Scout's search method to find stuff, for example:

$ipsum = App\Models\Post::search('Lorem')->get();

Enjoy!

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests