I added Meilisearch to the project, now its interface is available in the browser at :7700 and I see the following in my browser:
I installed Meilisearch via Laravel Sail utility, below is the content of my docker-compose.yml file:
And the contents of my .env file, which is related to the Meilisearch configuration:
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=masterKey
FORWARD_MEILISEARCH_PORT=7700
Now I'm trying to add the first index with the command:
sail artisan scout:import "App\Models\<model name>"
I'm getting an error:
MeiliSearch\Exceptions\CommunicationException
Failed to connect to 127.0.0.1 port 7700: Connection refused for "http://127.0.0.1:7700/indexes/<model name>s/documents?primaryKey=id".
I noticed that there is no data.ms file in the project. Its appearance indicates that meilisearch has been started. In some docker tutorials I have seen commands like:
docker run -p 7700:7700 -v "$(pwd)/data.ms:/data.ms" getmeili/meilisearch"
docker pull getmeili/meilisearch:latest && docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/data.ms:/data.ms \
getmeili/meilisearch:latest
... but I don't have a custom docker config, I have Laravel Sail!!!!!
Why is Mailisearch running in a browser and running on the port it's configured on, but I can't see the data.ms file and get an error when I try to add indexes for models? Please help me to understand the problem and fix it.
The problem was in incorrect configuration.
It was necessary to replace the host address 127.0.0.1 with value 'meilisearch' in the .env file like this:
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://meilisearch:7700
MEILISEARCH_KEY=masterKey
Similarly (but this was not the problem) it was necessary to replace the host address 127.0.0.1 with the value 'meilisearch' in the docker-compose.yml file in 'healthcheck' section like this:
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--spider", "http://meilisearch:7700/health"]
retries: 3
timeout: 5s