Skip to content

Commit

Permalink
Add meilisearch
Browse files Browse the repository at this point in the history
Replacement for ElasticSearch
  • Loading branch information
andrew-gardener committed Dec 11, 2024
1 parent 19c35eb commit 4eec7ee
Show file tree
Hide file tree
Showing 59 changed files with 2,601 additions and 2,366 deletions.
15 changes: 8 additions & 7 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ ROUTE_HOST=localhost
ROUTE_BASE=
TRUSTED_PROXIES=127.0.0.1

# Elasticsearch
ELASTICSEARCH_HOST=elasticsearch
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_USERNAME=elastic
ELASTICSEARCH_PASSWORD=password

# Feedback notifications
FEEDBACK_RECIPIENTS='[]'

Expand All @@ -57,4 +51,11 @@ EWZ_RECAPTCHA_ENABLED=false
###> excelwebzone/recaptcha-bundle ###
EWZ_RECAPTCHA_SITE_KEY=
EWZ_RECAPTCHA_SECRET=
###< excelwebzone/recaptcha-bundle ###
###< excelwebzone/recaptcha-bundle ###

###> meilisearch/search-bundle ###
# Uncomment the following line if you use Meilisearch through Docker
MEILISEARCH_URL=http://meilisearch:7700
MEILISEARCH_API_KEY="password"
MEILISEARCH_PREFIX=app_doceww_
###< meilisearch/search-bundle ###
25 changes: 12 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,29 @@ jobs:
mysql user: ${{ env.DB_USER }}
mysql password: ${{ env.DB_PASSWORD }}

- name: Runs Elasticsearch
uses: getong/[email protected]
with:
elasticsearch version: '8.9.2'
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
- name: Run Meilisearch
run: |
docker run -d \
-p 7700:7700 \
-e MEILI_MASTER_KEY='password' \
getmeili/meilisearch:v1.11.3
- name: Run Unit Tests
run: |
touch .env.test.local
echo DATABASE_URL="mysql://${{ env.DB_USER }}:${{ env.DB_PASSWORD }}@127.0.0.1:3306/${{ env.DB_NAME }}?serverVersion=mariadb-10.11.0" >> .env.test.local
echo ELASTICSEARCH_HOST="127.0.0.1" >> .env.test.local
echo ELASTICSEARCH_PORT="9200" >> .env.test.local
echo ELASTICSEARCH_USERNAME="elastic" >> .env.test.local
echo ELASTICSEARCH_PASSWORD="" >> .env.test.local
echo MEILISEARCH_URL="http://127.0.0.1:7700" >> .env.test.local
echo MEILISEARCH_API_KEY="password" >> .env.test.local
docker run --rm \
-v "${GITHUB_WORKSPACE}/.env.test.local":/var/www/html/.env.test.local \
--network host \
--platform=${{ matrix.platform }} \
${{ env.REGISTRY_IMAGE }}@${{ steps.build.outputs.digest }} make test
- name: Stop Meilisearch
run: |
docker rm $(docker stop $(docker ps -a -q --filter ancestor=getmeili/meilisearch:v1.11.3 --format="{{.ID}}"))
- name: Export digest
run: |
mkdir -p /tmp/digests
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ test.reset: ## Create a test database and load the fixtures in it
$(CONSOLE) --env=test doctrine:schema:validate --quiet
$(CONSOLE) --env=test doctrine:cache:clear-metadata --quiet
$(CONSOLE) --env=test doctrine:fixtures:load --quiet --no-interaction --group=dev
$(CONSOLE) --env=test fos:elastica:populate --quiet --no-debug
$(CONSOLE) --env=test meili:delete --quiet --no-debug
$(CONSOLE) --env=test meili:import --quiet --no-debug

test.clean: ## Clean Meilisearch
$(CONSOLE) --env=test meili:delete --quiet --no-debug

test.run: ## Directly run tests. Use optional path=/path/to/tests to limit target
$(PHPUNIT) $(path)

test: test.reset test.run ## Run all tests. Use optional path=/path/to/tests to limit target
test: test.reset test.run test.clean ## Run all tests. Use optional path=/path/to/tests to limit target

test.cover: test.reset ## Generate a test cover report
$(PHP) -dpcov.enabled=1 -dpcov.directory=. -dpcov.exclude="~vendor~" $(PHPUNIT) $(path) --coverage-html=coverage
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Next you must start the whole application

docker compose up -d --build

docker exec -it doceww_app ./bin/console fos:elastica:populate --no-debug
docker exec -it doceww_app ./bin/console meili:import --no-debug

doceww will now be available at `http://localhost:8080/`

Expand Down Expand Up @@ -52,9 +52,10 @@ example:

docker compose up -d --build

### Rebuilding the elasticsearch logs
### Rebuilding the meilisearch indexes

docker exec -it doceww_app ./bin/console fos:elastica:populate --no-debug
docker exec -it doceww_app ./bin/console meili:delete --no-debug
docker exec -it doceww_app ./bin/console meili:import --no-debug

### Viewing logs (each container)

Expand Down
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.15",
"friendsofsymfony/elastica-bundle": "^6.3",
"guzzlehttp/guzzle": "^7.7",
"knplabs/knp-menu-bundle": "^3.2",
"knplabs/knp-paginator-bundle": "^6.2",
"meilisearch/search-bundle": "^0.15.6",
"ninsuo/symfony-collection": "^2.1",
"nyholm/psr7": "^1.8",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.33",
"sensio/framework-extra-bundle": "^6.2",
"sfu-dhil/nines": "6.3.16",
"symfony/asset": "6.3.*",
Expand Down Expand Up @@ -82,7 +84,8 @@
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true,
"symfony/runtime": true
"symfony/runtime": true,
"php-http/discovery": true
}
},
"autoload": {
Expand Down
Loading

0 comments on commit 4eec7ee

Please sign in to comment.