Using the Meilisearch driver | laravel-site-search-go | Spatie       

 SPATIE  

laravel-site-search-go
======================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-site-search-go](https://spatie.be/docs/laravel-site-search-go/v1)  Advanced-usage  Using the Meilisearch driver

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-site-search-go/v1) 

  Using the Meilisearch driver    
- [ Introduction ](https://spatie.be/docs/laravel-site-search-go/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-site-search-go/v1/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-site-search-go/v1/requirements)
- [ Installation and setup ](https://spatie.be/docs/laravel-site-search-go/v1/installation-setup)
- [ About us ](https://spatie.be/docs/laravel-site-search-go/v1/about-us)
- [ Questions and issues ](https://spatie.be/docs/laravel-site-search-go/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-site-search-go/v1/changelog)
- [ Testing ](https://spatie.be/docs/laravel-site-search-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-site-search-go/v1/releasing)

Basic usage
-----------

- [ High level overview ](https://spatie.be/docs/laravel-site-search-go/v1/basic-usage/high-level-overview)
- [ Indexing your first site ](https://spatie.be/docs/laravel-site-search-go/v1/basic-usage/indexing-your-first-site)
- [ Retrieving results ](https://spatie.be/docs/laravel-site-search-go/v1/basic-usage/retrieving-results)
- [ Preventing content from being indexed ](https://spatie.be/docs/laravel-site-search-go/v1/basic-usage/preventing-content-from-being-indexed)
- [ Using a search profile ](https://spatie.be/docs/laravel-site-search-go/v1/basic-usage/using-a-search-profile)
- [ Listing indexes ](https://spatie.be/docs/laravel-site-search-go/v1/basic-usage/listing-indexes)
- [ Troubleshooting ](https://spatie.be/docs/laravel-site-search-go/v1/basic-usage/troubleshooting)

Advanced usage
--------------

- [ Creating multiple search indexes ](https://spatie.be/docs/laravel-site-search-go/v1/advanced-usage/creating-multiple-search-indexes)
- [ Using a custom indexer ](https://spatie.be/docs/laravel-site-search-go/v1/advanced-usage/using-a-custom-indexer)
- [ Indexing extra properties ](https://spatie.be/docs/laravel-site-search-go/v1/advanced-usage/indexing-extra-properties)
- [ Available events ](https://spatie.be/docs/laravel-site-search-go/v1/advanced-usage/available-events)
- [ Using the database driver ](https://spatie.be/docs/laravel-site-search-go/v1/advanced-usage/using-the-database-driver)
- [ Using the Meilisearch driver ](https://spatie.be/docs/laravel-site-search-go/v1/advanced-usage/using-the-meilisearch-driver)
- [ Building an admin integration ](https://spatie.be/docs/laravel-site-search-go/v1/advanced-usage/filament-integration)

 Using the Meilisearch driver
============================

###  On this page 

1. [ Setting up the Meilisearch driver ](#content-setting-up-the-meilisearch-driver)
2. [ Authenticating requests ](#content-authenticating-requests)
3. [ Customizing the connection URL ](#content-customizing-the-connection-url)
4. [ Customizing index settings ](#content-customizing-index-settings)

The Meilisearch driver supports synonyms and custom ranking rules. It requires a running Meilisearch instance.

Setting up the Meilisearch driver
-----------------------------------------------------------------------------------------------------------------------------------------------------------

Set the package's default driver:

```
sitesearch.New(func(cfg *sitesearch.Config) {
    cfg.DefaultDriver = "meilisearch"
})
```

You can also set `SITE_SEARCH_DRIVER=meilisearch` in your application's environment, or set a saved configuration's `Driver` field to `meilisearch` for one index.

See [the Meilisearch installation docs](https://www.meilisearch.com/docs/learn/getting_started/installation) to install and supervise the server. The package uses Laravel Go's application-scoped HTTP client. Tests can fake those requests with `httpclienttest`.

Every index, settings and document write waits for its Meilisearch task to succeed. A failed or canceled task returns an error. Context cancellation stops polling, and each write task has a one-minute timeout.

Authenticating requests
-----------------------------------------------------------------------------------------------------------------------------

Meilisearch exposes its API on port 7700 by default. Keep that port private or use [Meilisearch authentication](https://www.meilisearch.com/docs/learn/security/basic_security).

Set `meilisearch.apiKey` in the saved configuration's `Extra`:

```
{"meilisearch": {"apiKey": "your-api-key"}}
```

Use a key with the index, task, settings and document permissions needed by your application. Do not expose it to browsers. The driver does not follow redirects, so it will not forward the key to a redirected destination.

Customizing the connection URL
--------------------------------------------------------------------------------------------------------------------------------------------------

The default URL is `http://127.0.0.1:7700`. Set `meilisearch.url` in `Extra` to change it:

```
{"meilisearch": {"url": "https://search.example.com:7700"}}
```

Use an HTTP or HTTPS URL without embedded credentials, a query string or a fragment.

Customizing index settings
--------------------------------------------------------------------------------------------------------------------------------------

A Meilisearch index has [settings](https://www.meilisearch.com/docs/learn/configuration/settings) for searchable fields, ranking rules and synonyms. Set `meilisearch.indexSettings` in `Extra`. These settings are applied when a new physical index is created.

To search only URLs and descriptions:

```
{
    "meilisearch": {
        "indexSettings": {
            "searchableAttributes": ["url", "description"]
        }
    }
}
```

To add a synonym for the word computer:

```
{
    "meilisearch": {
        "indexSettings": {
            "synonyms": {"Macintosh": ["computer"]}
        }
    }
}
```

Custom properties live under the `extra` object in Go documents. That object is searchable by default. Use nested attribute names such as `extra.authorName` when configuring filters or searchable fields.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
