A site search engine

Overview

THIS PACKAGE IS IN DEVELOPMENT, DO NOT USE IN PRODUCTION YET

A site search engine

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package can crawl your entire site and index it.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-site-search

You can publish the config file with:

php artisan vendor:publish --provider="Spatie\SiteSearch\SiteSearchServiceProvider" --tag="laravel-site-search-config"

This is the contents of the published config file:

return [
    'sites' => [
        'default' => [
            'url' => env('APP_URL'),
            'driver' => Spatie\SiteSearch\Drivers\MeiliSearchDriver::class,
            'index_name' => 'default-site-search-index',
            'profile' => Spatie\SiteSearch\Profiles\DefaultSearchProfile::class,
        ],
    ],
];

Usage

Coming soon...

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Issues running first crawl

    Issues running first crawl

    I seem to be having some trouble getting my first index crawled. I've installed meilisearch in an azure cloud deployment. In my local laravel app, I've required this package and meilisearch-php sdk package.

    I created the index without issue and updated the table row to include {"meilisearch":{"url":"https:\/\/[SUBDOMAIN INSERTED].azurewebsites.net","apiKey":"[ADMIN KEY INSERTED]"}} where the two variables are populated with the correct information for my configuration. I have tested the Admin API key successfully in meilisearch on the web interface.

    Initially when I ran php artisan site-search:crawl I received an error about casting (an array was expected for array_map but one of the functions was returning an array as contract model).

    Doing some quick work to see if I could temporarily solve the problem with a simple cast, the issues just kept cascading down into other lines of code, leading me to believe that my installed versions were not meeting requirements.

    I had installed the latest version of meilisearch, but I noticed a suggested version much lower. So I reverted back to meilisearch-php v. 0.17.2 and the casting issues went away.

    However, now the crawl command is still throwing an error, saying that the Authorization header is missing. I'm at a loss at this point. I believe I've implemented all as instructed. Do you have any recommendations for me on where things might be going wrong?

    UPDATE: Poking at this a little further and I can see that this is still due to the meilisearch-php compatibility. v0.17.2 uses the old authorization header which is deprecated in the docker instance I deployed. If I edit the meilisearch-php vendor files directly to update the header then the error pushes on to another compatibility issue.

    So I guess what I need to know is for laravel-site-search v.1.2.0, what version of meilisearch-php is required? Because the requirements spec'd on the documentation site don't give any information on versioning, but there are clearly some compatibility issues that need to be resolved. Or perhaps you can update to allow compatibility with the newest meilisearch-php release?

    opened by NVV-WebManager 7
  • Introduce possibilty to modify the indexed URLs

    Introduce possibilty to modify the indexed URLs

    This PR introduces the possibility to modify the URL of a page before it is indexed. This makes it possible to strip away unwanted query parameters for example.

    Resolves #21

    opened by marcreichel 5
  • Error exception being thrown after running php artisan view:cache

    Error exception being thrown after running php artisan view:cache

    I've got an error saying directory does not exist in this package vendor directory after running php artisan view:cache. The log looks like the following:-

    [2022-01-18 14:46:42] local.ERROR: The "/home/sail/example-app/vendor/spatie/laravel-site-search/src/../resources/views" directory does not exist. {"exception":"[object] (Symfony\\Component\\Finder\\Exception\\DirectoryNotFoundException(code: 0): The \"/home/sail/example-app/vendor/spatie/laravel-site-search/src/../resources/views\" directory does not exist. at /home/sail/example-app/vendor/symfony/finder/Finder.php:592) [stacktrace] #0 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewCacheCommand.php(67): Symfony\\Component\\Finder\\Finder->in() #1 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewCacheCommand.php(36): Illuminate\\Foundation\\Console\\ViewCacheCommand->bladeFilesIn() #2 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(242): Illuminate\\Foundation\\Console\\ViewCacheCommand->Illuminate\\Foundation\\Console\\{closure}() #3 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewCacheCommand.php(37): Illuminate\\Support\\Collection->each() #4 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\ViewCacheCommand->handle() #5 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #6 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #7 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #8 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\\Container\\BoundMethod::call() #9 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call() #10 /home/sail/example-app/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute() #11 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run() #12 /home/sail/example-app/vendor/symfony/console/Application.php(1005): Illuminate\\Console\\Command->run() #13 /home/sail/example-app/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand() #14 /home/sail/example-app/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun() #15 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\\Component\\Console\\Application->run() #16 /home/sail/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run() #17 /home/sail/example-app/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle() #18 {main} "}

    opened by abuhurairah-aar 4
  • `highlightedSnippet()` does not work

    `highlightedSnippet()` does not work

    When rendering the search results and trying to print the $hit->highlightedSnippet() nothing gets returned but $hit->snippet() does return something (unhighlighted of course).

    Am I missing something?

    opened by marcreichel 2
  • In a Laravel 9.19 sail install, meilisearch throws cURL error 7 (Connection refused)

    In a Laravel 9.19 sail install, meilisearch throws cURL error 7 (Connection refused)

    I'm not sure why it's trying to request 127.0.0.1:7700

    My .env file has MEILISEARCH_HOST=http://meilisearch:7700

    In a sail shell, curl http://meilisearch:7700 works correctly. curl http://127.0.0.1:7700 does not.

    I can also access the Meilisearch UI in my browser at http://localhost:7700.

    Dispatching job to crawl `http://localhost:8085`
    
       MeiliSearch\Exceptions\CommunicationException 
    
      cURL error 7: Failed to connect to 127.0.0.1 port 7700 after 0 ms: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://127.0.0.1:7700/indexes
    
      at vendor/meilisearch/meilisearch-php/src/Http/Client.php:164
        160▕ 
        161▕         try {
        162▕             return $this->parseResponse($this->http->sendRequest($request));
        163▕         } catch (NetworkExceptionInterface $e) {
      ➜ 164▕             throw new CommunicationException($e->getMessage(), $e->getCode(), $e);
        165▕         }
        166▕     }
        167▕ 
        168▕     private function buildQueryString(array $queryParams = []): string
    
    opened by stephenr85 1
  • Fix highlightedSnippet looking in wrong place

    Fix highlightedSnippet looking in wrong place

    As others have noticed in a previous issue / discussion (https://github.com/spatie/laravel-site-search/issues/14 and https://github.com/spatie/laravel-site-search/discussions/16 respectively) that highlightedSnippet() was returning null but snippet() was returning content.

    Looking at both the Meilisearch docs (https://docs.meilisearch.com/reference/features/search_parameters.html#attributes-to-highlight) and the properties of Spatie\SiteSearch\SearchResults\Hit, the highlighted properties will actually be within an array called _formatted, whereas this package was previously looking for highlightedDescription, highlightedEntry or highlightedH1 (assuming the default MeiliSearchDriver was in use).

    The function itself will still either return null (if either _formatted isn't an array (which would only be the case if the attributesToHighlight search parameter is empty from what I can see) or the property name cannot be found in _formatted) or the string from the _formatted array.

    Thanks

    opened by SimonJulian 1
  • Fail to fetch the robots.txt file stops the crawler

    Fail to fetch the robots.txt file stops the crawler

    If for some reason fetching the robots.txt throws and exception the crawler stops. Setting ignoreRobots has no effect because fetching the file happens before checking if we want to ignore it or not.

    Maybe we can catch any exception when trying to fetch the robots.txt file and then check if we want to honor it and it is not null?

    What do you think @freekmurze?

    opened by geidelguerra 1
  • Fix event constructors

    Fix event constructors

    • The IndexedUrlEvent was missing the visibility keywords for constructor property promotion.
    • Added a missing space between the visibility and the property type.
    opened by sebdesign 1
Releases(1.4.1)
  • 1.4.1(Nov 2, 2022)

    What's Changed

    • Make the CrawlSiteJob unique by @riasvdv in https://github.com/spatie/laravel-site-search/pull/30

    New Contributors

    • @riasvdv made their first contribution in https://github.com/spatie/laravel-site-search/pull/30

    Full Changelog: https://github.com/spatie/laravel-site-search/compare/1.4.0...1.4.1

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Oct 24, 2022)

    What's Changed

    • Allow to customise job by @freekmurze in https://github.com/spatie/laravel-site-search/pull/29

    New Contributors

    • @freekmurze made their first contribution in https://github.com/spatie/laravel-site-search/pull/29

    Full Changelog: https://github.com/spatie/laravel-site-search/compare/1.3.0...1.4.0

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Sep 29, 2022)

  • 1.2.1(Aug 24, 2022)

    What's Changed

    • Bug fix indexs meilisearch by @mikzero in https://github.com/spatie/laravel-site-search/pull/28

    New Contributors

    • @mikzero made their first contribution in https://github.com/spatie/laravel-site-search/pull/28

    Full Changelog: https://github.com/spatie/laravel-site-search/compare/1.2.0...1.2.1

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Jan 19, 2022)

  • 1.1.1(Jan 19, 2022)

  • 1.1.0(Dec 11, 2021)

    What's Changed

    • Introduce possibilty to modify the indexed URLs by @marcreichel in https://github.com/spatie/laravel-site-search/pull/22

    New Contributors

    • @marcreichel made their first contribution in https://github.com/spatie/laravel-site-search/pull/22

    Full Changelog: https://github.com/spatie/laravel-site-search/compare/1.0.2...1.1.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Nov 29, 2021)

    What's Changed

    • Fix highlightedSnippet looking in wrong place by @SimonJulian in https://github.com/spatie/laravel-site-search/pull/20

    New Contributors

    • @SimonJulian made their first contribution in https://github.com/spatie/laravel-site-search/pull/20

    Full Changelog: https://github.com/spatie/laravel-site-search/compare/1.0.1...1.0.2

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Oct 26, 2021)

    What's Changed

    • Fix event constructors by @sebdesign in https://github.com/spatie/laravel-site-search/pull/12

    New Contributors

    • @sebdesign made their first contribution in https://github.com/spatie/laravel-site-search/pull/12

    Full Changelog: https://github.com/spatie/laravel-site-search/compare/1.0.0...1.0.1

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Oct 19, 2021)

  • 0.0.5(Oct 18, 2021)

  • 0.0.3(Oct 17, 2021)

  • 0.0.2(Oct 17, 2021)

Owner
Spatie
We create products and courses for the developer community
Spatie
SphinxQL Query Builder generates SphinxQL, a SQL dialect, which is used to query the Sphinx search engine. (Composer Package)

Query Builder for SphinxQL About This is a SphinxQL Query Builder used to work with SphinxQL, a SQL dialect used with the Sphinx search engine and it'

FoolCode 318 Oct 21, 2022
A metadata catalog and search engine for geospatialized data

resto is a metadata catalog and a search engine dedicated to geospatialized data. Originally, it’s main purpose it to handle Earth Observation satellite imagery but it can be used to store any kind of metadata localized in time and space.

Jerome Gasperi 50 Nov 17, 2022
Laravel search is package you can use it to make search query easy.

Laravel Search Installation First, install the package through Composer. composer require theamasoud/laravel-search or add this in your project's comp

Abdulrahman Masoud 6 Nov 2, 2022
Sphinx Search library provides SphinxQL indexing and searching features

Sphinx Search Sphinx Search library provides SphinxQL indexing and searching features. Introduction Installation Configuration (simple) Usage Search I

Ripa Club 62 Mar 14, 2022
A search package for Laravel 5.

Search Package for Laravel 5 This package provides a unified API across a variety of different full text search services. It currently supports driver

Mark Manos 354 Nov 16, 2022
A php trait to search laravel models

Searchable, a search trait for Laravel Searchable is a trait for Laravel 4.2+ and Laravel 5.0 that adds a simple search function to Eloquent Models. S

Nicolás López Jullian 2k Dec 27, 2022
Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch

TNTSearch Driver for Laravel Scout - Laravel 5.3 - 8.0 This package makes it easy to add full text search support to your models with Laravel 5.3 to 8

TNT Studio 1k Dec 27, 2022
Unmaintained: Laravel Searchy makes user driven searching easy with fuzzy search, basic string matching and more to come!

!! UNMAINTAINED !! This package is no longer maintained Please see Issue #117 Here are some links to alternatives that you may be able to use (I do no

Tom Lingham 533 Nov 25, 2022
Kirby docs search workflow for Alfred

Kirby Docs search workflow for Alfred 4 An ultra-fast Kirby Docs search workflow for Alfred 4 Installation Download the latest version Install the wor

Adam Kiss 30 Dec 29, 2022
Build and execute an Elasticsearch search query using a fluent PHP API

PACKAGE IN DEVELOPMENT, DO NOT USE YET Build and execute ElasticSearch queries using a fluent PHP API This package is a lightweight query builder for

Spatie 94 Dec 14, 2022
A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.

Apache Solr for TYPO3 CMS A TYPO3 extension that integrates the Apache Solr enterprise search server with TYPO3 CMS. The extension has initially been

Apache Solr for TYPO3 126 Dec 7, 2022
Support search in flarum by sonic

flarum-sonic Support search by Sonic Install Sonic following this guide Install the extension: composer require ganuonglachanh/sonic Change info in a

null 18 Dec 21, 2022
Your personal job-search assistant

JobsToMail Your personal job-search assistant About JobsToMail is an open source web application that allows users to sign up to receive emails with j

JobApis 93 Nov 13, 2022
Search among multiple models with ElasticSearch and Laravel Scout

For PHP8 support use php8 branch For Laravel Framework < 6.0.0 use 3.x branch The package provides the perfect starting point to integrate ElasticSear

Sergey Shlyakhov 592 Dec 25, 2022
This is an open source demo of smart search feature implemented with Laravel and Selectize plugin

Laravel smart search implementation See demo at: http://demos.maxoffsky.com/shop-search/ Tutorial at: http://maxoffsky.com/code-blog/laravel-shop-tuto

Maksim Surguy 215 Sep 8, 2022
Laravel package to search through multiple Eloquent models. Supports sorting, pagination, scoped queries, eager load relationships and searching through single or multiple columns.

Laravel Cross Eloquent Search This Laravel package allows you to search through multiple Eloquent models. It supports sorting, pagination, scoped quer

Protone Media 844 Dec 25, 2022
This modules provides a Search API Backend for Elasticsearch.

Search API ElasticSearch This modules provides a Search API Backend for Elasticsearch. This module uses the official Elasticsearch PHP Client. Feature

null 1 Jan 20, 2022
Laravel Searchable - This package makes it easy to get structured search from a variety of sources

This package makes it easy to get structured search from a variety of sources. Here's an example where we search through some model

Spatie 1.1k Dec 31, 2022
Search products, categories, brands or tags with ElasticSearch

ElasticSearch for Shopaholic This plugin allows you to use ElasticSearch as search engine for Shopaholic. Benefits Easy to install, easy to use Opened

Biz-Mark 4 Feb 18, 2022