File: README.md

package info (click to toggle)
golang-github-meilisearch-meilisearch-go 0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,084 kB
  • sloc: makefile: 9
file content (44 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Index Creation and Settings Example

This example shows how to create an index and configure its settings for better search.

## What it does

1. Create an "articles" index with "id" as primary key
2. Configure comprehensive settings:
   - Searchable attributes (title, content, author, tags)
   - Displayed attributes (what fields to return)
   - Filterable attributes (what can be used in filters)
   - Sortable attributes (what can be sorted)
   - Ranking rules (how to order results)
   - Stop words (common words to ignore)
   - Synonyms (alternative words)
   - Typo tolerance (allow spelling mistakes)
   - Pagination limits
3. Verify the settings were applied

## Settings configured

- **Searchable**: title, content, author, tags
- **Filterable**: category, author, publish_date, status, featured
- **Sortable**: publish_date, title, author
- **Ranking rules**: words, typo, proximity, attribute, sort, exactness
- **Stop words**: the, a, an, and, or, but, in, on, at, to, for, of, with, by
- **Synonyms**: programming = coding/development, javascript = js/ecmascript, golang = go
- **Typo tolerance**: 1 typo for 5+ letter words, 2 typos for 9+ letter words
- **Max results**: 1000 per search

## Configuration

```bash
export MEILI_HOST="http://localhost:7700"
export MEILI_API_KEY="your-api-key"
```

## Run it

```bash
go run ./examples/create_index_settings
```

The example will create an "articles" index, configure comprehensive settings, add sample articles, and demonstrate how the settings improve search results.