1 import { Note, Table } from "docs-ui"
2
3 export const metadata = {
4 title: `Medusa Search vs Meilisearch`,
5 keywords: [
6 "search",
7 "medusa search",
8 "meilisearch",
9 "comparison",
10 "search engine",
11 ],
12 }
13
14 # {metadata.title}
15
16 This guide compares Medusa Search and Meilisearch to help you decide which one to use for your Medusa project.
17
18 <Note title="Not a Cloud user yet?">
19
20 [Sign up for Cloud](../../sign-up/page.mdx) to use Medusa Search and other Cloud features.
21
22 </Note>
23
24 ## What is Medusa Search?
25
26 Medusa Search is a managed search service for Cloud projects. It stores your search indexes outside of your database and serves search queries for them, from full-text queries with relevance ranking to vector search over embeddings.
27
28 ---
29
30 ## What is Meilisearch?
31
32 Meilisearch is an open source search engine that provides full-text search, typo tolerance, and faceted search out of the box. You either run it yourself or subscribe to Meilisearch Cloud, then provision an index and manage its keys and settings for each environment.
33
34 ---
35
36 ## Comparison Summary
37
38 <Table>
39 <Table.Header>
40 <Table.Row>
41 <Table.HeaderCell>
42 Concern
43 </Table.HeaderCell>
44 <Table.HeaderCell>
45 Medusa Search
46 </Table.HeaderCell>
47 <Table.HeaderCell>
48 Meilisearch
49 </Table.HeaderCell>
50 </Table.Row>
51 </Table.Header>
52 <Table.Body>
53 <Table.Row>
54 <Table.Cell>
55
56 [Setup](#setup-and-infrastructure)
57
58 </Table.Cell>
59 <Table.Cell>
60 Medusa provisions the service and passes the credentials to your application.
61 </Table.Cell>
62 <Table.Cell>
63 Run the engine yourself, or create a Meilisearch Cloud project. Either way, add the host and key to every environment.
64 </Table.Cell>
65 </Table.Row>
66 <Table.Row>
67 <Table.Cell>
68
69 [Local development](#local-development)
70
71 </Table.Cell>
72 <Table.Cell>
73 The PostgreSQL provider indexes into your local database, so no service to run.
74 </Table.Cell>
75 <Table.Cell>
76 Run the same engine locally as a single binary or container.
77 </Table.Cell>
78 </Table.Row>
79 <Table.Row>
80 <Table.Cell>
81
82 [Integration code you maintain](#integration-with-medusa)
83
84 </Table.Cell>
85 <Table.Cell>
86
87 None by default. Medusa provides Medusa Search and manages the infrastructure for you out of the box.
88
89 </Table.Cell>
90 <Table.Cell>
91 A Search Module Provider you build and maintain to connect your application to Meilisearch and manage the search indexes.
92 </Table.Cell>
93 </Table.Row>
94 <Table.Row>
95 <Table.Cell>
96
97 [Per-environment isolation](#environments-and-previews)
98
99 </Table.Cell>
100 <Table.Cell>
101 Medusa manages one set of indexes per environment for you.
102 </Table.Cell>
103 <Table.Cell>
104 You name and provision an index per environment, or run an instance per environment.
105 </Table.Cell>
106 </Table.Row>
107 <Table.Row>
108 <Table.Cell>
109
110 [What you pay for](#cost-and-packaging)
111
112 </Table.Cell>
113 <Table.Cell>
114
115 No separate subscription. Your plan includes a monthly allowance of search requests, and anything above it is Flex Usage.
116
117 </Table.Cell>
118 <Table.Cell>
119 Your own infrastructure and engineering time when you self-host, or a Meilisearch Cloud subscription.
120 </Table.Cell>
121 </Table.Row>
122 <Table.Row>
123 <Table.Cell>
124
125 [Keeping the index current](#indexing-and-synchronization)
126
127 </Table.Cell>
128 <Table.Cell>
129 Medusa provides the indexing logic and keeps the indexes current automatically.
130 </Table.Cell>
131 <Table.Cell>
132 You must implement and maintain the indexing logic in your Algolia Search Module Provider to work with the Search Module.
133 </Table.Cell>
134 </Table.Row>
135 <Table.Row>
136 <Table.Cell>
137
138 [Typo tolerance and highlighting](#search-capabilities)
139
140 </Table.Cell>
141 <Table.Cell>
142 Both supported, and you opt into each one per query.
143 </Table.Cell>
144 <Table.Cell>
145 Supported and configurable per index.
146 </Table.Cell>
147 </Table.Row>
148 <Table.Row>
149 <Table.Cell>
150
151 [Vector search](#search-capabilities)
152
153 </Table.Cell>
154 <Table.Cell>
155 Hybrid search that blends text and vector results by a semantic ratio, on the Scale and Enterprise plans, with embeddings Medusa Search can create for you on the Enterprise plan.
156 </Table.Cell>
157 <Table.Cell>
158 Hybrid text and vector search, and a configured embedder can compute the embeddings.
159 </Table.Cell>
160 </Table.Row>
161 <Table.Row>
162 <Table.Cell>
163
164 [Sorting by an attribute](#search-capabilities)
165
166 </Table.Cell>
167 <Table.Cell>
168 Any number of fields, but not alongside a vector query.
169 </Table.Cell>
170 <Table.Cell>
171
172 Any attribute in `sortableAttributes`, alongside a query.
173
174 </Table.Cell>
175 </Table.Row>
176 <Table.Row>
177 <Table.Cell>
178
179 [Storefront querying](#storefront-integration)
180
181 </Table.Cell>
182 <Table.Cell>
183 Supported by Medusa's InstantSearch adapter.
184 </Table.Cell>
185 <Table.Cell>
186 Supported by Medusa's InstantSearch adapter.
187 </Table.Cell>
188 </Table.Row>
189 <Table.Row>
190 <Table.Cell>
191
192 [Admin dashboard search](#admin-dashboard-search)
193
194 </Table.Cell>
195 <Table.Cell>
196 Uses your indexes automatically.
197 </Table.Cell>
198 <Table.Cell>
199 Uses your indexes automatically.
200 </Table.Cell>
201 </Table.Row>
202 </Table.Body>
203 </Table>
204
205 ---
206
207 ## Setup and Infrastructure
208
209 ### Medusa Search
210
211 Medusa provisions Medusa Search for every Cloud environment. It passes the credentials to your Medusa application, which registers the provider for you. So, you don't need to manually configure or maintain the search infrastructure. You can immediately start searching.
212
213 ### Meilisearch
214
215 Meilisearch takes considerably more work before you can run a single search:
216
217 1. Run the engine yourself, or create a Meilisearch Cloud project. Self-hosting also puts the host, the backups, the monitoring, and every version upgrade on you.
218 2. Provision an index for every environment, and pick a naming scheme that keeps them apart.
219 3. Generate a write key and a search-only key, then store both as environment variables in every Cloud environment.
220 4. Configure the index settings, including the order of `searchableAttributes`, the `filterableAttributes`, the `sortableAttributes`, typo tolerance, and the ranking rules.
221 5. Repeat steps 2 to 4 for every environment you add, and keep the settings identical across all of them.
222
223 Step 4 is the one that keeps costing you. Meilisearch stores the index settings on the instance rather than in your codebase, so they drift out of version control unless you push them from code as part of a deployment. A fresh instance with the defaults answers the same query with different relevance than your production one.
224
225 You then connect Meilisearch to Medusa, which requires creating a Search Module Provider as explained in the [Integration with Medusa](#integration-with-medusa) section.
226
227 <Note title="Self-hosting next to Cloud">
228
229 If your Medusa application runs on Cloud, a self-hosted Meilisearch instance still needs a host somewhere, and search queries then travel from your Cloud environment to that host. Factor that hop and the instance's availability into the decision, since your storefront's search depends on both.
230
231 </Note>
232
233 ### Local Development
234
235 Medusa Search runs on Cloud only. In local development, Medusa registers the [PostgreSQL Search Module Provider](!resources!/infrastructure-modules/search/providers/postgres) instead, which indexes into your local database. You declare and test an index without running a search engine on your machine. You can also [connect to your environment's search endpoint](../page.mdx#use-search-in-local-development).
236
237 For MeiliSearch, you run the same engine locally that you run in production, so relevance behaves the same in both, and there's no second provider whose feature set you have to check against.
238
239 ---
240
241 ## Integration with Medusa
242
243 ### With Medusa Search
244
245 Medusa provides Medusa Search out of the box. You don't need to spend time building, maintaining, or configuring it yourself. The infrastructure is ready for you to use immediately, allowing you to focus on defining your search indexes and integrating them into your application.
246
247 ### With Meilisearch
248
249 Medusa doesn't maintain a Search Module Provider for Meilisearch, so you have to build a custom one. A [Search Module Provider](!resources!/infrastructure-modules/search/providers) implements the interface the Search Module calls to interact with the search engine.
250
251 The provider needs to handle several responsibilities:
252
253 1. Provide the connection layer to create, migrate, and delete a physical index from an index definition, including translating each field type and modifier into Meilisearch's index settings.
254 2. Upsert and delete documents in batches, and delete by a filter.
255 3. Compile the Search Module's filter tree, including `$or`, `$not`, and several operators on one field, into a Meilisearch filter expression.
256 4. Compile facets, sorting, pagination, and search options into Meilisearch queries, and decide what to reject when the engine can't serve a request.
257 5. Map Meilisearch's response back into the shape the module expects, including the relevance score and the facet results.
258
259 So, by integrating Meilisearch, you spend more time building and maintaining the search infrastructure yourself, compared to using Medusa Search, which is ready to use out of the box.
260
261 Refer to [Search Module Providers](!resources!/infrastructure-modules/search/providers) for how the module loads and calls a provider, and to [Create Search Module Provider](!resources!/references/search/provider) for the interface to implement.
262
263 ---
264
265 ## Environments and Previews
266
267 ### Medusa Search
268
269 Medusa gives each Cloud environment its own set of Medusa Search indexes, scoped by the environment's handle, so a preview environment never writes to production indexes. When you configure a base environment in the [shared previews settings](../../environments/preview/page.mdx#manage-shared-previews-settings), Cloud copies the base environment's indexes into the new preview environment along with its database.
270
271 ### Meilisearch
272
273 With Meilisearch, index isolation is your responsibility, and you choose between two approaches:
274
275 - **One instance, an index prefix per environment.** Cheaper, but every environment shares the instance's resources, and a bad write in a preview can reach a production index if the prefix is wrong.
276 - **An instance per environment.** Fully isolated, and each instance costs infrastructure or a Meilisearch Cloud project.
277
278 Either way, a preview environment starts with an empty index and needs a full sync before search works.
279
280 ---
281
282 ## Cost and Packaging
283
284 <Table>
285 <Table.Header>
286 <Table.Row>
287 <Table.HeaderCell>
288 Option
289 </Table.HeaderCell>
290 <Table.HeaderCell>
291 What you pay for
292 </Table.HeaderCell>
293 <Table.HeaderCell>
294 What drives the cost up
295 </Table.HeaderCell>
296 </Table.Row>
297 </Table.Header>
298 <Table.Body>
299 <Table.Row>
300 <Table.Cell>
301 Medusa Search
302 </Table.Cell>
303 <Table.Cell>
304
305 No separate subscription, since Medusa Search is available on all Cloud plans. Each plan includes a monthly allowance of search requests. Refer to [Plans & Pricing](../../pricing/page.mdx) for the allowance your plan includes.
306
307 </Table.Cell>
308 <Table.Cell>
309
310 Search requests beyond your plan's allowance, which count as [Flex Usage](../../usage/page.mdx#what-is-flex-usage).
311
312 </Table.Cell>
313 </Table.Row>
314 <Table.Row>
315 <Table.Cell>
316 Meilisearch, self-hosted
317 </Table.Cell>
318 <Table.Cell>
319 The infrastructure you run it on, plus the engineering time to operate it. The engine itself is open source.
320 </Table.Cell>
321 <Table.Cell>
322 Index size and traffic, since both drive the instance you need. Operational time doesn't scale down with the catalog.
323 </Table.Cell>
324 </Table.Row>
325 <Table.Row>
326 <Table.Cell>
327 Meilisearch Cloud
328 </Table.Cell>
329 <Table.Cell>
330 A separate subscription, priced on the documents you store and the searches you run.
331 </Table.Cell>
332 <Table.Cell>
333 Catalog size, traffic, and a project per environment.
334 </Table.Cell>
335 </Table.Row>
336 </Table.Body>
337 </Table>
338
339 Meilisearch also has some important considerations to keep in mind:
340
341 - **The real cost of self-hosting.** The engine is free, and the on-call rotation, the upgrade work, and the disk you size for the index are not.
342 - **Document count, not product count.** If you flatten variants or localized fields into separate documents, your document count grows much faster than your catalog does.
343
344 ### Other Cloud Usage MeiliSearch Affects
345
346 Using Meilisearch for Search on Cloud can drive up the costs of the following Cloud usage metrics:
347
348 - **Data Transfer** covers external service communications, so every index write and every search your backend sends to Meilisearch counts toward it, along with the responses. This applies to a self-hosted instance and to Meilisearch Cloud alike, since both sit outside your Medusa server.
349 - **Compute** covers the indexing work, since the seed and the event handlers that write to Meilisearch run in your Medusa application.
350
351 Refer to [Usage](../../usage/page.mdx) on how to monitor both metrics.
352
353 ---
354
355 ## Indexing and Synchronization
356
357 The Search Module orchestrates the flow for indexing and data synchronization. It uses the methods implemented in the configured provider to interact with the underlying search engine, whether it's Medusa Search or Meilisearch.
358
359 Medusa maintains Medusa Search, so it already implements all the necessary methods for indexing and synchronization.
360
361 For Meilisearch, it's your responsibility to provide an implementation that translates the Search Module's calls into Meilisearch API requests, allowing the Search Module to manage indexes and push documents into Meilisearch. You must maintain this implementation as Medusa updates the Search Module and its indexing logic.
362
363 ---
364
365 ## Search Capabilities
366
367 The Search Module provides the interface to perform search queries, but each Search Module Provider must translate those features into the specific capabilities and syntax of the underlying search engine.
368
369 <Table>
370 <Table.Header>
371 <Table.Row>
372 <Table.HeaderCell>
373 Capability
374 </Table.HeaderCell>
375 <Table.HeaderCell>
376 Medusa Search
377 </Table.HeaderCell>
378 <Table.HeaderCell>
379 Meilisearch
380 </Table.HeaderCell>
381 </Table.Row>
382 </Table.Header>
383 <Table.Body>
384 <Table.Row>
385 <Table.Cell>
386 Full-text relevance
387 </Table.Cell>
388 <Table.Cell>
389 Relevance scales with the weight you set on each field.
390 </Table.Cell>
391 <Table.Cell>
392
393 A configurable ranking order, and the order of `searchableAttributes` sets their importance.
394
395 </Table.Cell>
396 </Table.Row>
397 <Table.Row>
398 <Table.Cell>
399 Typo tolerance
400 </Table.Cell>
401 <Table.Cell>
402
403 Supported and configurable per index and query, with word-length thresholds and field exemptions.
404
405 </Table.Cell>
406 <Table.Cell>
407 Supported, and you can tune or disable it per index and per attribute.
408 </Table.Cell>
409 </Table.Row>
410 <Table.Row>
411 <Table.Cell>
412 Filters
413 </Table.Cell>
414 <Table.Cell>
415
416 Every operator the Search Module offers, including `$or`, `$not`, and several operators on one field.
417
418 </Table.Cell>
419 <Table.Cell>
420
421 A filter expression syntax, on attributes you add to `filterableAttributes`.
422
423 </Table.Cell>
424 </Table.Row>
425 <Table.Row>
426 <Table.Cell>
427 Synonyms and stop words
428 </Table.Cell>
429 <Table.Cell>
430 Not supported. An index that declares them fails at startup.
431 </Table.Cell>
432 <Table.Cell>
433 Both supported as index settings.
434 </Table.Cell>
435 </Table.Row>
436 <Table.Row>
437 <Table.Cell>
438 Facets
439 </Table.Cell>
440 <Table.Cell>
441 Value and range facets. The hits, the count, and every facet of a query run as one search request.
442 </Table.Cell>
443 <Table.Cell>
444 Facet distribution and facet search on filterable attributes.
445 </Table.Cell>
446 </Table.Row>
447 <Table.Row>
448 <Table.Cell>
449 Highlighting and cropping
450 </Table.Cell>
451 <Table.Cell>
452
453 Supported on searchable fields, with your own markers and optional snippets.
454
455 </Table.Cell>
456 <Table.Cell>
457 Supported per query, with configurable markers.
458 </Table.Cell>
459 </Table.Row>
460 <Table.Row>
461 <Table.Cell>
462 Sorting by an attribute
463 </Table.Cell>
464 <Table.Cell>
465 Any number of fields, but not alongside a vector query.
466 </Table.Cell>
467 <Table.Cell>
468
469 Any attribute in `sortableAttributes`, alongside a query, with no extra index.
470
471 </Table.Cell>
472 </Table.Row>
473 <Table.Row>
474 <Table.Cell>
475 Vector and semantic search
476 </Table.Cell>
477 <Table.Cell>
478 Hybrid search that blends text and vector results by a semantic ratio, on the Scale and Enterprise plans. You compute the embeddings, or Medusa Search creates them for you on the Enterprise plan.
479 </Table.Cell>
480 <Table.Cell>
481 Hybrid search that blends text and vector results by a semantic ratio, with an embedder that can compute the embeddings.
482 </Table.Cell>
483 </Table.Row>
484 <Table.Row>
485 <Table.Cell>
486 Geo search
487 </Table.Cell>
488 <Table.Cell>
489 Not supported. An index that declares a geo field fails at startup.
490 </Table.Cell>
491 <Table.Cell>
492 Supported, with geo filters and sorting by distance.
493 </Table.Cell>
494 </Table.Row>
495 <Table.Row>
496 <Table.Cell>
497 Deep pagination
498 </Table.Cell>
499 <Table.Cell>
500 Up to the 10,000th result.
501 </Table.Cell>
502 <Table.Cell>
503 A configurable maximum number of total hits caps it.
504 </Table.Cell>
505 </Table.Row>
506 <Table.Row>
507 <Table.Cell>
508 Multi-tenancy on one index
509 </Table.Cell>
510 <Table.Cell>
511 Filter per query in your API route.
512 </Table.Cell>
513 <Table.Cell>
514 Tenant tokens carry a filter that the engine enforces on every query the token makes.
515 </Table.Cell>
516 </Table.Row>
517 </Table.Body>
518 </Table>
519
520 ---
521
522 ## Storefront Integration
523
524 [InstantSearch](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/) is a family of open source UI libraries, which render a search interface from widgets such as a search box, a hit list, facet filters, and pagination. It's available for plain JavaScript, React, Vue, and Angular.
525
526 Medusa's [InstantSearch adapter](!resources!/instantsearch) connects those widgets to Medusa's Search Module. It works with any Search Module Provider you integrate in your Medusa application, including both Medusa Search and your custom Meilisearch provider.
527
528 ```tsx
529 import {
530 createInstantSearchAdapter,
531 } from "@medusajs/instantsearch-adapter"
532 import { sdk } from "./sdk"
533 import {
534 Configure,
535 InstantSearch,
536 } from "react-instantsearch"
537
538 const PRODUCT_INDEX_NAME = "product"
539
540 export const { searchClient } = createInstantSearchAdapter({
541 sdk,
542 path: "/store/search",
543 })
544
545 const Search = () => (
546 <InstantSearch
547 indexName={PRODUCT_INDEX_NAME}
548 searchClient={searchClient}
549 >
550 <Configure hitsPerPage={12} />
551 {/* Render search widgets */}
552 </InstantSearch>
553 )
554 ```
555
556 Refer to the [InstantSearch Adapter guide](!resources!/instantsearch) for more details and examples of setting up search and filters.
557
558 ---
559
560 ## Admin Dashboard Search
561
562 The Medusa Admin dashboard's global search calls the [Admin Search API route](!api!/admin/search/search-admin), which uses the Search Module for every entity that has an index and falls back to database queries for the rest. Declaring an index for an entity therefore improves admin search with no extra work.
563
564 This is agnostic across different Search Module Providers, so it works the same for Medusa Search or your custom Meilisearch provider.
565
566 ---
567
568 ## Comparisons to Other Search Engines
569
570 The following guides compare Medusa Search to other search engines:
571
572 - [All engines compared](../comparison/page.mdx)
573 - [Medusa vs PostgreSQL](../postgres/page.mdx)
574 - [Medusa vs Algolia](../algolia/page.mdx)