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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
os: [ubuntu-latest]
php: [8.3, 8.4]
laravel: [11.*, 12.*]
laravel: [12.*]
stability: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
"meilisearch/meilisearch-php": "^1.0",
"guzzlehttp/guzzle": "^7.3",
"http-interop/http-factory-guzzle": "^1.0",
"illuminate/support": "^10.0 || ^11.0 || ^12.0",
"statamic/cms": "^6.0"
"illuminate/support": "^12.0",
"statamic/cms": "^6.0.0-beta.4",
"spatie/laravel-ray": "^1.0@dev"
},
"require-dev": {
"laravel/pint": "^1.21",
"orchestra/testbench": "^9.0 || ^10.0",
"orchestra/testbench": "^10.0",
"phpunit/phpunit": "^11.5.10"
},
"autoload": {
Expand Down Expand Up @@ -68,5 +69,6 @@
"developer": "Statamic Rad Pack"
}
},
"minimum-stability": "dev"
"minimum-stability": "dev",
"prefer-stable": true
}
9 changes: 0 additions & 9 deletions config/statamic-meilisearch.php

This file was deleted.

27 changes: 8 additions & 19 deletions src/Meilisearch/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,12 @@ public function insert($document)
return $this->insertMultiple(collect([$document]));
}

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

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

return $this;
public function fields(Searchable $searchable)
{
return array_merge(
$this->searchables()->fields($searchable),
$this->getDefaultFields($searchable)
);
}

public function delete($document)
Expand All @@ -66,9 +55,9 @@ public function exists()
}
}

protected function insertDocuments(Documents $documents)
public function insertDocuments(Documents $documents)
{
$this->getIndex()->updateDocuments($documents->all());
$this->getIndex()->updateDocuments($documents->values()->all());
}

protected function deleteIndex()
Expand Down
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-meilisearch.php', 'statamic-meilisearch');

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

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

}

Search::extend('meilisearch', function (Application $app, array $config, $name, $locale = null) {
$client = $app->makeWith(Client::class, [
'url' => $config['credentials']['url'],
Expand Down
6 changes: 4 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ protected function resolveApplicationConfiguration($app)
{
parent::resolveApplicationConfiguration($app);

// add driver
$app['config']->set('statamic.search.drivers.meilisearch', [
'credentials' => [
'url' => 'http://localhost:7700',
'secret' => 'masterKey',
],
]);

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

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