Skip to content

Commit

Permalink
Migrate from Alibaba Cloud OpenSearch to OpenSearch (#57)
Browse files Browse the repository at this point in the history
* Migrate from Alibaba Cloud OpenSearch to OpenSearch

* Rector Rectify

* Remove zing/alibabacloud-opensearch

* Rename property

* Fix typehint

* Fix searchable data

* Fix query where in

* Fix phpstan errors

* Fix phpstan errors

* wip

* Update README.md

* Update README.md

---------

Co-authored-by: zingimmick <[email protected]>
  • Loading branch information
zingimmick and zingimmick authored Jun 1, 2023
1 parent 9a1ad31 commit 850d628
Show file tree
Hide file tree
Showing 15 changed files with 901 additions and 917 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ on:

jobs:
tests:
services:
search-server:
image: opensearchproject/opensearch
ports:
- 9200:9200
env:
discovery.type: single-node
plugins.security.disabled: 'true'

runs-on: ubuntu-latest
strategy:
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ composer require zing/laravel-scout-opensearch
return [
// ...
'opensearch' => [
"access_key" => env('OPENSEARCH_ACCESS_KEY', 'your-opensearch-access-key'),
"secret" => env('OPENSEARCH_SECRET', 'your-opensearch-secret'),
"host" => env('OPENSEARCH_HOST', 'your-opensearch-host'),
"options" => [
"debug" => env('OPENSEARCH_DEBUG', false),
],
'hosts' => [env('OPENSEARCH_HOST', 'localhost:9200')],
'basicAuthentication' => [env('OPENSEARCH_USERNAME', 'admin'), env('OPENSEARCH_PASSWORD', 'admin')],
'retries' => env('OPENSEARCH_RETRYS', 2),
],
];
```
Expand All @@ -41,7 +38,7 @@ class SearchableModel extends Model

public function searchableAs(): string
{
return '{{APP_NAME}}.{{TABLE_NAME}}';
return 'searchable_models_index';
}

/**
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
"sort-packages": true,
"preferred-install": "dist",
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"php-http/discovery": true
}
},
"require": {
"php": "^8.0",
"ext-json": "*",
"laravel/scout": "^8.5 || ^9.1 || ^10.0",
"zing/alibabacloud-opensearch": "^3.3"
"opensearch-project/opensearch-php": "^2.0"
},
"require-dev": {
"mockery/mockery": "~1.3.3 || ^1.4.2",
Expand Down
7 changes: 6 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ parameters:
paths:
- src
- tests
excludePaths:
analyse:
- tests/OpenSearchEngineTest.php
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::getScoutKey\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::getScoutKeyName\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::getScoutModelsByIds\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::queryScoutModelsByIds\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::scoutMetadata\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::searchableAs\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::toSearchableArray\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder<Illuminate\\Database\\Eloquent\\Model>::unsearchable\(\).#'
- '#Call to an undefined method Illuminate\\Support\\HigherOrderCollectionProxy<string, Illuminate\\Database\\Eloquent\\Model, Illuminate\\Database\\Eloquent\\Collection>::pushSoftDeleteMetadata\(\).#'
- '#Trying to access array offset on value of type null#'
- '#Call to an undefined method Illuminate\\Support\\HigherOrderCollectionProxy<string, Illuminate\\Database\\Eloquent\\Model, Illuminate\\Database\\Eloquent\\Collection>::getScoutKey\(\).#'
- '#Parameter \#1 ...\$arrays of function array_merge expects array, int given.#'
13 changes: 7 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage/>
<testsuites>
<testsuite name="Laravel Scout custom engine for OpenSearch Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
Loading

0 comments on commit 850d628

Please sign in to comment.