Skip to content

Commit

Permalink
move search options under the local driver heading and some other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Feb 22, 2024
1 parent 30243b5 commit f25c0c4
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions content/collections/docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,31 @@ This will create dynamic indexes named after the specified sites:

If you have a localized index and include searchables that do not support localization (like assets or users), they will appear in each localized index.

### Search Options

The built in search driver supports multiple options you can pass in.
## Drivers

Statamic takes a "driver" based approach to search engines. Drivers are interchangeable so you can gain new features or integrate with 3rd party services without ever having to change your data or frontend.

The native [local driver](#local-driver) is simple and requires no additional configuration, while the included [algolia driver](#algolia-driver) makes it super simple to integrate with [Algolia](https://algolia.com), one of the leading search as a service providers.

You can build your own custom search drivers or look at the [Addon Marketplace](https://statamic.com/addons/tags/search) to see what the community has already created.

### Local {#local-driver}

The `local` driver (aka "Comb") uses JSON to store key/value pairs, mapping fields to the content IDs they belong to. It lacks advanced features you would see in a service like Algolia, but hey, It Just Works™. It's a great way to get a search started quickly.

#### Settings

You may provide local driver specific settings in a `settings` array.

```php
'driver' => 'local',
'searchables' => 'all',
'settings' => [ // [tl! **:start]
'min_characters' => 3,
'use_stemming' => true,
] // [tl! **:end]
```

- `match_weights`: An array of weights for each field to use when calculating relevance scores. Defaults to `null`.
- `min_characters`: The minimum number of characters required in a search query. Defaults to `null`.
Expand All @@ -299,18 +321,6 @@ The built in search driver supports multiple options you can pass in.
- `stop_words`: An array of stop words to exclude from the search query. Defaults to `['the', 'a', 'an']`.
- `include_properties`: An array of properties to include in the search results. Defaults to `$this->config['fields'] ?? ['title']`.

## Drivers

Statamic takes a "driver" based approach to search engines. Drivers are interchangeable so you can gain new features or integrate with 3rd party services without ever having to change your data or frontend.

The native [local driver](#local-driver) is simple and requires no additional configuration, while the included [algolia driver](#algolia-driver) makes it super simple to integrate with [Algolia](https://algolia.com), one of the leading search as a service providers.

You can build your own custom search drivers or look at the [Addon Marketplace](https://statamic.com/addons/tags/search) to see what the community has already created.

### Local {#local-driver}

The `local` driver uses JSON to store key/value pairs, mapping fields to the content IDs they belong to. It lacks advanced features like weighting and relevance matching, but hey, It Just Works™. It's a great way to get a search started quickly.

### Algolia {#algolia-driver}

Algolia is a full-featured search and navigation cloud service. They offer fast and relevant search with results in under 100 ms (99% under 20 ms). Results are prioritized and displayed using a customizable ranking formula.
Expand All @@ -335,7 +345,7 @@ composer require algolia/algoliasearch-client-php

Statamic will automatically create and sync your indexes as you create and modify entries once you kick off the initial index creation by running the command `php please search:update`.

### Settings
#### Settings
You may provide Algolia-specific [settings](https://www.algolia.com/doc/api-reference/settings-api-parameters/) in a `settings` array.

```php
Expand All @@ -355,7 +365,7 @@ You may provide Algolia-specific [settings](https://www.algolia.com/doc/api-refe
] // [tl! **:end]
```

### Templating with Algolia
#### Templating with Algolia

We recommend using the [Javascript implementation](https://www.algolia.com/doc/api-client/getting-started/install/javascript/?language=javascript) to communicate directly with them for the frontend of your site. This bypasses Statamic entirely in the request lifecycle and is incredibly fast.

Expand Down

0 comments on commit f25c0c4

Please sign in to comment.