Skip to content

Commit ef02272

Browse files
authored
Merge pull request #185 from makeplane/open-search-config-for-advanced-search
Advanced search - OpenSearch configuration
2 parents 4932bba + 250102c commit ef02272

3 files changed

Lines changed: 307 additions & 2 deletions

File tree

mint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
]
116116
},
117117
"self-hosting/govern/communication",
118-
"self-hosting/govern/configure-dns-email-service",
119118
"self-hosting/govern/database-and-storage",
120119
"self-hosting/govern/custom-domain",
121120
"self-hosting/govern/configure-ssl",
@@ -129,6 +128,8 @@
129128
"self-hosting/govern/integrations/slack"
130129
]
131130
},
131+
"self-hosting/govern/configure-dns-email-service",
132+
"self-hosting/govern/advanced-search",
132133
"self-hosting/govern/external-secrets",
133134
"self-hosting/govern/reverse-proxy",
134135
"self-hosting/govern/environment-variables",
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
---
2+
title: Configure OpenSearch for advanced search
3+
sidebarTitle: OpenSearch for Advanced search
4+
---
5+
6+
Plane uses OpenSearch to provide advanced search capabilities across your workspace. This guide walks you through setting up OpenSearch integration on your self-hosted instance.
7+
8+
<Note>
9+
Advanced search requires a Pro or Business plan license.
10+
</Note>
11+
12+
## Before you begin
13+
14+
You'll need:
15+
16+
- An OpenSearch 2.x instance (self-hosted or managed service like AWS OpenSearch).
17+
- Redis 6.2 or later (for batch processing).
18+
- Celery workers running for background index updates.
19+
20+
## What you get with advanced search
21+
22+
Once configured, advanced search provides:
23+
24+
- **Full-text search** across work items, projects, cycles, modules, pages, and more
25+
- **Fuzzy matching** that tolerates typos and variations in spelling
26+
- **Autocomplete** with instant suggestions as you type
27+
- **Multi-entity search** that searches across all content types in a single query
28+
29+
Users can access advanced search using the global search shortcut (Cmd/Ctrl + K) or search within specific projects and sections.
30+
31+
## Configure OpenSearch
32+
33+
Set environment variables in your Plane configuration. See [Environment variables reference](/self-hosting/govern/environment-variables#opensearch) for details.
34+
35+
### For Docker deployments
36+
37+
1. **Add configuration to your environment file**
38+
39+
Edit `/opt/plane/plane.env`.
40+
```bash
41+
# OpenSearch Settings
42+
OPENSEARCH_ENABLED=1
43+
OPENSEARCH_URL=https://your-opensearch-instance:9200/
44+
OPENSEARCH_USERNAME=admin
45+
OPENSEARCH_PASSWORD=your-secure-password
46+
OPENSEARCH_INDEX_PREFIX=plane
47+
```
48+
49+
2. **Restart Plane services**
50+
```bash
51+
prime-cli restart
52+
```
53+
54+
or if managing containers directly:
55+
```bash
56+
docker compose down
57+
docker compose up -d
58+
```
59+
60+
3. **Create search indices**
61+
62+
Access the API container and create the necessary indices:
63+
```bash
64+
# Access the API container
65+
docker exec -it plane-api-1 sh
66+
67+
# Create all search indices (run once)
68+
python manage.py manage_search_index index rebuild --force
69+
```
70+
71+
4. **Index your existing data**
72+
73+
Index all existing content into OpenSearch:
74+
```bash
75+
# For small datasets
76+
python manage.py manage_search_index document index --force
77+
78+
# For large datasets (recommended)
79+
python manage.py manage_search_index --background document index --force
80+
```
81+
82+
The background option processes indexing through Celery workers, which is better for instances with large amounts of data.
83+
84+
### For Kubernetes deployments
85+
86+
The Plane Helm chart provides auto-setup for OpenSearch. If you're using your own OpenSearch instance, configure it through Helm values.
87+
88+
1. **Configure Helm values**
89+
90+
Get the current values file:
91+
```bash
92+
helm show values plane/plane-enterprise > values.yaml
93+
```
94+
95+
Edit `values.yaml` to add OpenSearch configuration:
96+
```yaml
97+
env:
98+
# OpenSearch configuration
99+
opensearch_remote_url: 'https://your-opensearch-instance:9200/'
100+
opensearch_remote_username: 'admin'
101+
opensearch_remote_password: 'your-secure-password'
102+
opensearch_index_prefix: 'plane'
103+
```
104+
105+
Refer to the [Plane Helm chart documentation](https://artifacthub.io/packages/helm/makeplane/plane-enterprise?modal=values&path=env.opensearch_remote_url) for complete values structure.
106+
107+
2. **Upgrade your deployment**
108+
```bash
109+
helm upgrade --install plane-app plane/plane-enterprise \
110+
--create-namespace \
111+
--namespace plane \
112+
-f values.yaml \
113+
--timeout 10m \
114+
--wait \
115+
--wait-for-jobs
116+
```
117+
118+
3. **Create search indices**
119+
120+
Run these commands in the API pod.
121+
```bash
122+
# Get the API pod name
123+
API_POD=$(kubectl get pods -n plane --no-headers | grep api | head -1 | awk '{print $1}')
124+
125+
# Create all search indices (run once)
126+
kubectl exec -n plane $API_POD -- python manage.py manage_search_index index rebuild --force
127+
```
128+
129+
4. **Index your existing data**
130+
Run these commands in the API pod.
131+
```bash
132+
# For small datasets
133+
kubectl exec -n plane $API_POD -- python manage.py manage_search_index document index --force
134+
135+
# For large datasets (recommended)
136+
kubectl exec -n plane $API_POD -- python manage.py manage_search_index --background document index --force
137+
```
138+
139+
## Verify the setup
140+
141+
### Check OpenSearch connection
142+
143+
Test that Plane can connect to your OpenSearch instance:
144+
```bash
145+
# Access your API container or pod
146+
docker exec -it plane-api-1 sh # For Docker
147+
# OR
148+
kubectl exec -n plane $API_POD -- sh # For Kubernetes
149+
150+
# Start Python shell
151+
python manage.py shell
152+
```
153+
154+
Then run:
155+
```python
156+
from django.conf import settings
157+
from opensearchpy import OpenSearch
158+
159+
client = OpenSearch(
160+
hosts=[settings.OPENSEARCH_DSL['default']['hosts']],
161+
http_auth=settings.OPENSEARCH_DSL['default']['http_auth'],
162+
use_ssl=True,
163+
verify_certs=False
164+
)
165+
166+
# Check cluster health
167+
print(client.cluster.health())
168+
169+
# List indices - you should see your Plane indices
170+
print(client.cat.indices(format='json'))
171+
```
172+
173+
### Verify indices were created
174+
175+
List all created indices:
176+
```bash
177+
python manage.py manage_search_index list
178+
```
179+
180+
You should see indices for work items, projects, cycles, modules, pages, and other searchable entities.
181+
182+
### Test search functionality
183+
184+
1. Sign in to your Plane instance.
185+
2. Press **Cmd/Ctrl + K** to open global search.
186+
3. Type a search query and verify results appear.
187+
4. Test search within projects, work items, and pages.
188+
189+
## Maintenance
190+
191+
### Resync data
192+
193+
If search results become stale or inconsistent, resync your data:
194+
```bash
195+
python manage.py manage_search_index document index --force
196+
```
197+
198+
This reindexes all content without recreating the index structure.
199+
200+
### Complete rebuild
201+
202+
For a complete reset (recreates indices and reindexes all data):
203+
```bash
204+
# Recreate all indices
205+
python manage.py manage_search_index index rebuild --force
206+
207+
# Reindex all documents
208+
python manage.py manage_search_index document index --force
209+
```
210+
211+
Use this if index structure needs updating or if you're experiencing persistent issues.
212+
213+
### Monitor logs
214+
215+
Check API logs OpenSearch-related errors:
216+
217+
**Docker:**
218+
```bash
219+
docker compose logs api | grep -i opensearch
220+
```
221+
222+
**Kubernetes:**
223+
```bash
224+
kubectl logs -n plane -l app.kubernetes.io/component=api | grep -i opensearch
225+
```
226+
227+
## Understanding how it works
228+
229+
Advanced search in Plane maintains search indices separately from your main database. This separation is why search can be fast even with thousands of work items - OpenSearch is purpose-built for search operations, while your database handles transactional operations.
230+
231+
### Why Plane uses OpenSearch
232+
233+
Traditional database searches struggle with fuzzy matching and typos. If you search for "authentcation" (with a typo), a database won't find "authentication". OpenSearch handles this naturally because it analyzes text differently - it breaks words into tokens, normalizes variations, and understands linguistic patterns.
234+
235+
This is why autocomplete feels instant. OpenSearch pre-processes text to match partial words, while your database would need to scan entire tables to achieve similar results.
236+
237+
### The synchronization challenge
238+
239+
The trade-off with separate search indices is keeping them synchronized with your database. When someone updates a work item, that change must reach OpenSearch for search results to remain accurate.
240+
241+
Plane solves this through an event-driven architecture. Every time data changes in your database, Django emits a signal. These signals trigger updates to OpenSearch.
242+
243+
### Batching for efficiency
244+
245+
Direct, immediate updates would overwhelm both your database and OpenSearch. Imagine a user creating 50 work items in quick succession, that would mean 50 separate API calls to OpenSearch, each with network overhead.
246+
247+
Instead, Plane batches updates through Redis. When a signal fires, the update goes into a Redis queue. A Celery worker processes this queue every 5 seconds, combining multiple updates into efficient batch operations. This is why you might notice a brief delay (up to 5 seconds) before new content appears in search results.
248+
249+
The batching pattern also provides resilience. If OpenSearch is temporarily unavailable, updates accumulate in Redis and process once connectivity returns. This requires Redis 6.2+ which supports the LPOP count operation needed for efficient batch retrieval.
250+
251+
### The complete flow
252+
```
253+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
254+
│ Plane Web │────▶│ Plane API │────▶│ OpenSearch │
255+
│ (Search) │ │ (Query) │ │ (Indices) │
256+
└─────────────────┘ └─────────────────┘ └─────────────────┘
257+
258+
│ Database signals
259+
260+
┌─────────────────┐
261+
│ Redis Queue │
262+
│ (Batching) │
263+
└─────────────────┘
264+
265+
│ Celery task (every 5s)
266+
267+
┌─────────────────┐
268+
│ Celery Worker │────▶ Batch updates
269+
│ (Processing) │
270+
└─────────────────┘
271+
```
272+
273+
When you search, queries bypass this synchronization process entirely. The Plane API sends your search query directly to OpenSearch, which returns results almost instantly. Your database isn't involved in search queries at all — this is the key to search performance.
274+
275+
### Index organization
276+
277+
Plane creates nine separate indices in OpenSearch, one for each searchable entity type. This separation might seem redundant - why not put everything in one index?
278+
279+
The answer lies in how different entities need different search behaviors. Work items use fuzzy matching and field prioritization (title matches rank higher than description matches). Projects emphasize metadata filtering—status, member counts, and timelines. Pages analyze long-form content structure.
280+
281+
Each index is optimized for its content type:
282+
283+
| Index | Content | Search Features |
284+
|-------|---------|-----------------|
285+
| `{prefix}_issues` | Work items | Full-text search, field weighting (title > description), state filtering |
286+
| `{prefix}_issue_comments` | Comments | Comment search within work items, parent-child relationships |
287+
| `{prefix}_projects` | Projects | Project discovery, metadata filtering (dates, counts, status) |
288+
| `{prefix}_cycles` | Cycles | Cycle search, time-based filtering and aggregations |
289+
| `{prefix}_modules` | Modules | Module/sprint search, planning aggregations |
290+
| `{prefix}_pages` | Pages | Page content search, rich text analysis for long-form content |
291+
| `{prefix}_workspaces` | Workspaces | Workspace search and discovery |
292+
| `{prefix}_issue_views` | Saved views | Saved view search and filtering |
293+
| `{prefix}_teamspaces` | Teamspaces | Teamspace discovery |
294+
295+
The `{prefix}` is whatever you configured in `OPENSEARCH_INDEX_PREFIX`, or empty if you didn't set a prefix. This prefix exists because you might run multiple Plane instances pointing to the same OpenSearch cluster. The prefix prevents different instances from accidentally sharing or conflicting with each other's indices.

self-hosting/govern/environment-variables.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ This is where you'll make all configuration changes. Remember to restart the ins
137137
| **GITLAB_CLIENT_ID** | OAuth client ID for GitLab integration. | |
138138
| **GITLAB_CLIENT_SECRET** | OAuth client secret for GitLab integration. | |
139139

140+
### OpenSearch
141+
142+
| Variable | Description | Default Value |
143+
|----------|-------------|---------|
144+
| `OPENSEARCH_ENABLED` | Enable OpenSearch integration | `1` |
145+
| `OPENSEARCH_URL` | OpenSearch endpoint URL | `https://opensearch.example.com:9200/` |
146+
| `OPENSEARCH_USERNAME` | Authentication username | `admin` |
147+
| `OPENSEARCH_PASSWORD` | Authentication password | `your-secure-password` |
148+
| `OPENSEARCH_INDEX_PREFIX` | Prefix for all index names (useful for multi-tenant setups) | (empty) |
149+
140150
### API settings
141151

142152
| Variable | Description | Default Value |
@@ -233,7 +243,6 @@ The environment configuration file is located at:
233243
| **AWS_S3_BUCKET_NAME** | S3 bucket name for file storage. All uploads will be stored in this bucket. | `uploads` |
234244
| **FILE_SIZE_LIMIT** | Maximum file upload size in bytes. | `5242880` (5MB) |
235245

236-
237246
### Security settings
238247

239248
| Variable | Description | Default Value |

0 commit comments

Comments
 (0)