Skip to content

Scout 9 Support #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
accd8f8
Scout 9 Support
devNoiseConsulting Jul 22, 2022
86c3769
Limiting Supported Versions
devNoiseConsulting Feb 7, 2023
67dfeee
PostgresEngine Update
devNoiseConsulting Feb 8, 2023
7f5c735
Merge branch 'master' into laravel-10-compatibility
devNoiseConsulting Feb 8, 2023
02a5c4b
Laravel v10 Update
devNoiseConsulting Feb 14, 2023
fc6ac48
No Laravel Scout v10
devNoiseConsulting Feb 15, 2023
8297ab8
Forked It
devNoiseConsulting Feb 24, 2023
061544d
Merge branch 'laravel-10-compatibility'
devNoiseConsulting Feb 24, 2023
33d7000
Update README.md
devNoiseConsulting Feb 24, 2023
a18db80
Starting Static Analysis
devNoiseConsulting Feb 26, 2023
24e6aab
Laravel Scout v10
devNoiseConsulting Mar 21, 2023
b6eb400
Merge branch 'master' into larastan
devNoiseConsulting Mar 21, 2023
aa29b68
Duster and Pint
devNoiseConsulting Mar 21, 2023
73e303b
PostgresConnection fix
devNoiseConsulting Mar 21, 2023
a707941
Builder::macro fix
devNoiseConsulting Mar 29, 2023
b812c10
Builder::macro fix
devNoiseConsulting Mar 29, 2023
02ca105
Merge branch 'larastan' of https://github.com/devNoiseConsulting/lara…
devNoiseConsulting Mar 29, 2023
df5e7aa
Refactor PostgresEngine::map
devNoiseConsulting Mar 29, 2023
d0fe967
Rollback Builder::macro
devNoiseConsulting Mar 30, 2023
35ecdd8
Larastan Level 8
devNoiseConsulting Apr 5, 2023
d6fea0d
Changes for Testing
devNoiseConsulting Apr 25, 2023
e71dbbd
Fixing Testing
devNoiseConsulting Apr 25, 2023
6349dcf
Larastan Level 9
devNoiseConsulting Apr 27, 2023
2111ea1
Larastan Level 9 II
devNoiseConsulting Apr 27, 2023
67dc6f5
Github Action Tweaks
devNoiseConsulting Apr 27, 2023
8e5dd7e
Larastan Level 9 III
devNoiseConsulting Apr 28, 2023
71deb33
Merge pull request #4 from devNoiseConsulting/9.x
devNoiseConsulting Apr 28, 2023
9dd69c1
Laravel Scout v11
devNoiseConsulting Nov 30, 2024
be2f9b7
Larastan and Duster
devNoiseConsulting Nov 30, 2024
7a8b68e
No Scout 11
devNoiseConsulting Nov 30, 2024
3470141
Making tests happy
devNoiseConsulting Nov 30, 2024
c677cde
Merge pull request #6 from devNoiseConsulting/laravel-11-compatibility
devNoiseConsulting Nov 30, 2024
2398283
Fixed PHPUnit complaints of risky tests with no assertions.
willvincent Mar 4, 2025
6f0a634
Update .gitignore to ignore phpstorm .idea directory.
willvincent Mar 4, 2025
4a3cf53
Add queryCallback, whereIn and whereNotIn support.
willvincent Mar 4, 2025
0e45a3b
Fix softdelete handling.
willvincent Mar 4, 2025
2c7fec0
Update composer.json - Laravel 12
willvincent Mar 14, 2025
d92d5f5
Merge pull request #8 from willvincent/master
devNoiseConsulting Apr 21, 2025
b9a0657
Laravel 12 compatibility
devNoiseConsulting Apr 21, 2025
70383ed
Workflow fix
devNoiseConsulting Apr 21, 2025
e4830f9
Workflox fix 2
devNoiseConsulting Apr 21, 2025
b4ac99a
Workflow Fix 3
devNoiseConsulting Apr 21, 2025
22b18a7
Workflow fix 4
devNoiseConsulting Apr 21, 2025
d83da84
Workflow Fix 5
devNoiseConsulting Apr 21, 2025
33d9c8a
Workflow fix 6
devNoiseConsulting Apr 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 42 additions & 47 deletions .github/workflows/tests.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,52 +1,47 @@
name: tests

on:
push:
branches:
- master
pull_request:
push:
branches:
- master
- 9.x
pull_request:

jobs:
tests:

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4]
laravel: [^6.0, ^7.0, ^8.0]
scout: [^7.0, ^8.0]
exclude:
- php: 7.2
laravel: ^8.0
- laravel: ^8.0
scout: ^7.0
include:
- php: 8.0
laravel: ^8.0
scout: ^8.0

name: Test PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - Scout ${{ matrix.scout }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: |
composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
composer require "illuminate/database=${{ matrix.laravel }}" --no-update
composer require "illuminate/support=${{ matrix.laravel }}" --no-update
composer require "laravel/scout=${{ matrix.scout }}" --no-update
composer update --prefer-dist --no-interaction --no-progress

- name: Run tests
run: vendor/bin/phpunit --verbose
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.3, 8.4]
laravel: [^11, ^12]
scout: [^10]

name: Test PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - Scout ${{ matrix.scout }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: |
composer remove larastan/larastan --dev --no-update
composer remove orchestra/testbench --dev --no-update
composer remove tightenco/duster --dev --no-update
composer remove laravel/pint --dev --no-update
composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
composer require "illuminate/database=${{ matrix.laravel }}" --no-update
composer require "illuminate/support=${{ matrix.laravel }}" --no-update
composer require "laravel/scout=${{ matrix.scout }}" --no-update
composer update --prefer-dist --no-interaction --no-progress

- name: Run tests
run: vendor/bin/phpunit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/vendor
.phpunit.result.cache
composer.lock
composer.lock
.DS_Store
.idea
73 changes: 10 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
# PostgreSQL Full Text Search Engine for Laravel Scout

[![Latest Version on Packagist](https://img.shields.io/packagist/v/pmatseykanets/laravel-scout-postgres.svg?style=flat-square)](https://packagist.org/packages/pmatseykanets/laravel-scout-postgres)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
![tests](https://github.com/pmatseykanets/laravel-scout-postgres/workflows/tests/badge.svg)
[![StyleCI](https://styleci.io/repos/67233265/shield)](https://styleci.io/repos/67233265)
[![Total Downloads](https://img.shields.io/packagist/dt/pmatseykanets/laravel-scout-postgres.svg?style=flat-square)](https://packagist.org/packages/pmatseykanets/laravel-scout-postgres)
[![License](https://poser.pugx.org/pmatseykanets/laravel-scout-postgres/license)](https://github.com/pmatseykanets/laravel-scout-postgres/blob/master/LICENSE.md)
![Build Status](https://github.com/devnoiseconsulting/laravel-scout-postgres-tsvector/workflows/tests/badge.svg)
[![Latest Stable Version](https://img.shields.io/packagist/v/devnoiseconsulting/laravel-scout-postgres-tsvector.svg)](https://packagist.org/packages/devnoiseconsulting/laravel-scout-postgres-tsvector)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md)

This package makes it easy to use native PostgreSQL Full Text Search capabilities with [Laravel Scout](http://laravel.com/docs/master/scout).

If you find this package usefull, please consider bying me a coffee.

<a href='https://ko-fi.com/V7V43MXAO' target='_blank'><img height='28' style='border:0px;height:28px;' src='https://cdn.ko-fi.com/cdn/kofi2.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

## Contents

- [Installation](#installation)
- [Laravel](#laravel)
- [Lumen](#lumen)
- [Configuration](#configuration)
- [Configuring the Engine](#configuring-the-engine)
- [Configuring PostgreSQL](#configuring-postgresql)
Expand All @@ -36,8 +28,8 @@ If you find this package usefull, please consider bying me a coffee.

You can install the package via composer:

``` bash
composer require pmatseykanets/laravel-scout-postgres
```bash
composer require devnoiseconsulting/laravel-scout-postgres-tsvector
```

### Laravel
Expand All @@ -52,52 +44,6 @@ If you're using Laravel < 5.5 or if you have package auto-discovery turned off y
],
```

### Lumen

Scout service provider uses `config_path` helper that is not included in Lumen.
To fix this include the following snippet either directly in `bootstrap.app` or in your autoloaded helpers file i.e. `app/helpers.php`.

```php
if (! function_exists('config_path')) {
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
function config_path($path = '')
{
return app()->basePath() . '/config'.($path ? DIRECTORY_SEPARATOR.$path : $path);
}
}
```

Create the `scout.php` config file in `app/config` folder with the following contents

```php
<?php

return [
'driver' => env('SCOUT_DRIVER', 'pgsql'),
'prefix' => env('SCOUT_PREFIX', ''),
'queue' => false,
'pgsql' => [
'connection' => 'pgsql',
'maintain_index' => true,
'config' => 'english',
],
];
```

Register service providers:

```php
// bootstrap/app.php
$app->register(Laravel\Scout\ScoutServiceProvider::class);
$app->configure('scout');
$app->register(ScoutEngines\Postgres\PostgresEngineServiceProvider::class);
```

## Configuration

### Configuring the Engine
Expand Down Expand Up @@ -126,7 +72,7 @@ Specify the database connection that should be used to access indexed documents

### Configuring PostgreSQL

Make sure that an appropriate [default text search configuration](https://www.postgresql.org/docs/9.5/static/runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG) is set globbaly (in `postgresql.conf`), for a particular database (`ALTER DATABASE ... SET default_text_search_config TO ...`) or alternatively set `default_text_search_config` in each session.
Make sure that an appropriate [default text search configuration](https://www.postgresql.org/docs/14/runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG) is set globbaly (in `postgresql.conf`), for a particular database (`ALTER DATABASE ... SET default_text_search_config TO ...`) or alternatively set `default_text_search_config` in each session.

To check the current value

Expand Down Expand Up @@ -265,7 +211,7 @@ $posts = App\Post::search('fat & (cat | rat)')
->usingTsQuery()->get()

// websearch_to_tsquery()
// uses web search syntax
// uses web search syntax
$posts = App\Post::search('"sad cat" or "fat rat" -mouse')
->usingWebSearchQuery()->get()

Expand All @@ -281,13 +227,13 @@ Please see the [official documentation](http://laravel.com/docs/master/scout) on

## Testing

``` bash
```bash
composer test
```

## Security

If you discover any security related issues, please email pmatseykanets@gmail.com instead of using the issue tracker.
If you discover any security related issues, please email flynnmj@devnoise.com instead of using the issue tracker.

## Changelog

Expand All @@ -299,6 +245,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Credits

- [Michael Flynn](https://github.com/devNoiseConsulting)
- [Peter Matseykanets](https://github.com/pmatseykanets)
- [All Contributors](../../contributors)

Expand Down
31 changes: 20 additions & 11 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "pmatseykanets/laravel-scout-postgres",
"name": "devnoiseconsulting/laravel-scout-postgres-tsvector",
"description": "PostgreSQL Full Text Search Driver for Laravel Scout",
"keywords": [
"laravel",
Expand All @@ -9,29 +9,38 @@
"full text search",
"FTS"
],
"homepage": "https://github.com/pmatseykanets/laravel-scout-postgres",
"homepage": "https://github.com/devNoiseConsulting/laravel-scout-postgres-tsvector",
"license": "MIT",
"support": {
"issues": "https://github.com/pmatseykanets/laravel-scout-postgres/issues",
"source": "https://github.com/pmatseykanets/laravel-scout-postgres"
"issues": "https://github.com/devNoiseConsulting/laravel-scout-postgres-tsvector/issues",
"source": "https://github.com/devNoiseConsulting/laravel-scout-postgres-tsvector"
},
"authors": [
{
"name": "Michael Flynn",
"email": "flynnmj@devnoise.com",
"homepage": "https://github.com/devNoiseConsulting"
},
{
"name": "Peter Matseykanets",
"email": "pmatseykanets@gmail.com",
"homepage": "https://github.com/pmatseykanets"
}
],
"require": {
"php": "^7.2|^8.0",
"illuminate/contracts": "~6.0|~7.0|~8.0",
"illuminate/database": "~6.0|~7.0|~8.0",
"illuminate/support": "~6.0|~7.0|~8.0",
"laravel/scout": "~7.0|~8.0"
"php": "^8.1|^8.2|^8.3|^8.4",
"illuminate/contracts": "^10|^11|^12",
"illuminate/database": "^10|^11|^12",
"illuminate/support": "^10|^11|^12",
"laravel/scout": "^10|^11|^12"
},
"require-dev": {
"phpunit/phpunit": "^8.3",
"mockery/mockery": "^1.2.3"
"larastan/larastan": "^3.3",
"laravel/pint": "^1.22",
"mockery/mockery": "^1.6",
"orchestra/testbench": "^10.2",
"phpunit/phpunit": "^12.1",
"tightenco/duster": "^2.7"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 21 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:searchableAs\\(\\)\\.$#"
count: 2
path: src/PostgresEngine.php

-
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:toSearchableArray\\(\\)\\.$#"
count: 1
path: src/PostgresEngine.php
-
message: "#^Call to an undefined method TModel of Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:searchableAs\\(\\)\\.$#"
count: 2
path: src/PostgresEngine.php

-
message: "#^Call to an undefined method TModel of Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:getDeletedAtColumn\\(\\)\\.$#"
count: 2
path: src/PostgresEngine.php

10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- phpstan-baseline.neon

parameters:

paths:
- src/

# Level 9 is the highest level
level: 9
21 changes: 6 additions & 15 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
Loading