Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
matrix:
os: [ubuntu-latest]
php: [8.3, 8.4]
laravel: [11.*, 12.*]
statamic: [5.*, 6.*]
laravel: [12.*]
statamic: [6.*]
dependency-version: [prefer-stable]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - S${{ matrix.statamic }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"php": "^8.2",
"guzzlehttp/guzzle": "^7.3",
"http-interop/http-factory-guzzle": "^1.0",
"illuminate/support": "^11.0 || ^12.0",
"statamic/cms": "^5.38 || ^6.0",
"illuminate/support": "^12.0",
"statamic/cms": "^6.0.0-beta.4",
"typesense/typesense-php": "^4.9"
},
"require-dev": {
"laravel/pint": "^1.17",
"orchestra/testbench": "^8.14 || ^9.0 || ^10.0",
"phpunit/phpunit": "^10.0 || ^11.0"
"orchestra/testbench": "^10.0",
"phpunit/phpunit": "^11.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -58,5 +58,7 @@
"name": "Typesense",
"description": "Typesense search driver for Statamic"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
9 changes: 0 additions & 9 deletions config/statamic-typesense.php

This file was deleted.

10 changes: 0 additions & 10 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ class ServiceProvider extends AddonServiceProvider
{
public function bootAddon()
{
$this->mergeConfigFrom(__DIR__.'/../config/statamic-typesense.php', 'statamic-typesense');

if ($this->app->runningInConsole()) {

$this->publishes([
__DIR__.'/../config/statamic-typesense.php' => config_path('statamic-typesense.php'),
], 'statamic-typesense-config');

}

Search::extend('typesense', function (Application $app, array $config, $name, $locale = null) {
$client = new Client($config['client'] ?? []);

Expand Down
24 changes: 6 additions & 18 deletions src/Typesense/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,12 @@ public function insert($document)
return $this->insertMultiple(collect([$document]));
}

public function insertMultiple($documents)
public function fields(Searchable $searchable)
{
$documents
->chunk(config('statamic-typesense.insert_chunk_size', 100))
->each(function ($documents, $index) {
$documents = $documents
->filter()
->map(fn ($document) => array_merge(
$this->searchables()->fields($document),
$this->getDefaultFields($document),
))
->values()
->toArray();

$this->insertDocuments(new Documents($documents));
});

return $this;
return array_merge(
$this->searchables()->fields($searchable),
$this->getDefaultFields($searchable)
);
}

public function delete($document)
Expand All @@ -73,7 +61,7 @@ public function exists()
}
}

protected function insertDocuments(Documents $documents)
public function insertDocuments(Documents $documents)
{
$this->getOrCreateIndex()->documents->import($documents->all(), ['action' => 'upsert']);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ protected function resolveApplicationConfiguration($app)
{
parent::resolveApplicationConfiguration($app);

// add typesense driver
$app['config']->set('statamic.search.drivers.typesense', [
'client' => [
'api_key' => env('TYPESENSE_API_KEY', 'xyz'),
Expand All @@ -40,7 +39,10 @@ protected function resolveApplicationConfiguration($app)
],
]);

// add typesense index
$app['config']->set('statamic.search.indexes.cp', [
'driver' => 'null',
]);

$app['config']->set('statamic.search.indexes.typesense_index', [
'driver' => 'typesense',
'searchables' => ['collection:pages'],
Expand Down