Raw
1 import { Note, Table } from "docs-ui"
2
3 export const metadata = {
4 title: `Medusa Search vs Algolia`,
5 keywords: [
6 "search",
7 "medusa search",
8 "algolia",
9 "comparison",
10 "search engine",
11 ],
12 }
13
14 # {metadata.title}
15
16 This guide compares Medusa Search and Algolia 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 Algolia?
31
32 Algolia is a hosted search service that provides full-text search, typo tolerance, and relevance tuning out of the box. It requires you to create an account, provision an index, and manage the search keys and configuration 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 Algolia
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 Create an account, provision an index, generate keys, and add them 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 No local engine. Local development points at a real Algolia index.
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 Algolia 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.
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 A separate subscription, priced on the records you store and the search requests you make.
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 [Sorting by an attribute](#search-capabilities)
152
153 </Table.Cell>
154 <Table.Cell>
155 Any number of fields, but not alongside a vector query.
156 </Table.Cell>
157 <Table.Cell>
158 Needs a replica index per sort order.
159 </Table.Cell>
160 </Table.Row>
161 <Table.Row>
162 <Table.Cell>
163
164 [Storefront querying](#storefront-integration)
165
166 </Table.Cell>
167 <Table.Cell>
168 Supported by Medusa's InstantSearch adapter.
169 </Table.Cell>
170 <Table.Cell>
171 Supported by Medusa's InstantSearch adapter.
172 </Table.Cell>
173 </Table.Row>
174 <Table.Row>
175 <Table.Cell>
176
177 [Admin dashboard search](#admin-dashboard-search)
178
179 </Table.Cell>
180 <Table.Cell>
181 Uses your indexes automatically.
182 </Table.Cell>
183 <Table.Cell>
184 Uses your indexes automatically.
185 </Table.Cell>
186 </Table.Row>
187 </Table.Body>
188 </Table>
189
190 ---
191
192 ## Setup and Infrastructure
193
194 ### Medusa Search
195
196 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.
197
198 ### Algolia
199
200 Algolia takes considerably more work before you can run a single search. Algolia has no self-hosted option, so it operates the servers, but you configure and maintain everything around them:
201
202 1. Create an Algolia account and application.
203 2. Provision an index for every environment, and pick a naming scheme that keeps them apart.
204 3. Generate an admin key for writes and a search-only key for reads, then store both as environment variables in every Cloud environment.
205 4. Configure the index settings, including searchable attributes, faceting, ranking rules, and typo tolerance.
206 5. Repeat steps 2 to 4 for every environment you add, and keep the settings identical across all of them.
207
208 Step 4 is the one that keeps costing you. Index settings are dashboard configuration in Algolia by default, so they live outside your codebase and drift out of version control unless you push them through the API as part of a deployment.
209
210 Only after all of that do you connect Algolia to Medusa, which requires creating a Search Module Provider as explained in the [Integration with Medusa](#integration-with-medusa) section.
211
212 ### Local Development
213
214 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).
215
216 Algolia has no local engine, so local development points at a real Algolia index, usually a separate development one. Every developer either shares that index or gets their own, and both choices cost you records.
217
218 ---
219
220 ## Integration with Medusa
221
222 This is the largest difference between the two, since it decides how much search code you own.
223
224 ### With Medusa Search
225
226 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.
227
228 ### With Algolia
229
230 Medusa doesn't maintain a Search Module Provider for Algolia, 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.
231
232 The provider needs to handle several responsibilities:
233
234 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 Algolia's index settings.
235 2. Upsert and delete documents in batches, and delete by a filter.
236 3. Compile the Search Module's filter tree, including `$or`, `$not`, and several operators on one field, into Algolia's filter syntax.
237 4. Compile facets, sorting, pagination, and search options into Algolia queries, and decide what to reject when Algolia can't serve a request.
238 5. Map Algolia's response back into the shape the module expects, including the relevance score and the facet results.
239
240 So, by integrating Algolia, 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.
241
242 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.
243
244 ---
245
246 ## Environments and Previews
247
248 ### Medusa Search
249
250 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.
251
252 ### Algolia
253
254 With Algolia, index isolation is your responsibility. The usual approach is an index name prefix per environment, set through an environment variable, plus a decision about what a preview environment searches.
255
256 A preview that points at the production index is a write risk, and a preview with an empty index needs a full sync before search works. Each environment's records also count toward your record allowance, so preview environments have a price.
257
258 ---
259
260 ## Cost and Packaging
261
262 The two options bill for different things, which makes a direct price comparison misleading. Compare the shape of the cost instead:
263
264 <Table>
265 <Table.Header>
266 <Table.Row>
267 <Table.HeaderCell>
268 Option
269 </Table.HeaderCell>
270 <Table.HeaderCell>
271 What you pay for
272 </Table.HeaderCell>
273 <Table.HeaderCell>
274 What drives the cost up
275 </Table.HeaderCell>
276 </Table.Row>
277 </Table.Header>
278 <Table.Body>
279 <Table.Row>
280 <Table.Cell>
281 Medusa Search
282 </Table.Cell>
283 <Table.Cell>
284
285 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.
286
287 </Table.Cell>
288 <Table.Cell>
289
290 Search requests beyond your plan's allowance, which count as [Flex Usage](../../usage/page.mdx#what-is-flex-usage).
291
292 </Table.Cell>
293 </Table.Row>
294 <Table.Row>
295 <Table.Cell>
296 Algolia
297 </Table.Cell>
298 <Table.Cell>
299 A separate subscription, priced on the records you store and the search requests you make.
300 </Table.Cell>
301 <Table.Cell>
302 Catalog size, replica indexes, non-production indexes, traffic, and the plan tier that a feature requires.
303 </Table.Cell>
304 </Table.Row>
305 </Table.Body>
306 </Table>
307
308 Algolia also has some important considerations to keep in mind:
309
310 - **Sorting.** Each sort order needs its own replica index in Algolia, and a standard replica holds its own copy of the records. Several sort orders on a large catalog multiply the records that Algolia bills you for.
311 - **Record count, not product count.** If you flatten variants or localized fields into separate records in Algolia, your record count grows much faster than your catalog does.
312
313 ### Other Cloud Usage Algolia Affects
314
315 Using Algolia for Search on Cloud can drive up the costs of the following Cloud usage metrics:
316
317 - **Data Transfer** covers external service communications, so every index write and every search your backend sends to Algolia counts toward it, along with the responses. A storefront that searches through your API routes puts every query on this metric.
318 - **Compute** covers the indexing work, since the seed and the event handlers that write to Algolia run in your Medusa application.
319
320 Refer to [Usage](../../usage/page.mdx) on how to monitor both metrics.
321
322 ---
323
324 ## Indexing and Synchronization
325
326 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 Algolia.
327
328 Medusa maintains Medusa Search, so it already implements all the necessary methods for indexing and synchronization.
329
330 For Algolia, it's your responsibility to provide an implementation that translates the Search Module's calls into Algolia API requests, allowing the Search Module to manage indexes and push documents into Algolia. You must maintain this implementation as Medusa updates the Search Module and its indexing logic.
331
332 ---
333
334 ## Search Capabilities
335
336 The Search Module provides the interface to perform search queries, but each Search Module Provider must translates those features into the specific capabilities and syntax of the underlying search engine.
337
338 <Table>
339 <Table.Header>
340 <Table.Row>
341 <Table.HeaderCell>
342 Capability
343 </Table.HeaderCell>
344 <Table.HeaderCell>
345 Medusa Search
346 </Table.HeaderCell>
347 <Table.HeaderCell>
348 Algolia
349 </Table.HeaderCell>
350 </Table.Row>
351 </Table.Header>
352 <Table.Body>
353 <Table.Row>
354 <Table.Cell>
355 Full-text relevance
356 </Table.Cell>
357 <Table.Cell>
358 Relevance scales with the weight you set on each field.
359 </Table.Cell>
360 <Table.Cell>
361 Configurable ranking rules and custom ranking on top of the default tie-breaking.
362 </Table.Cell>
363 </Table.Row>
364 <Table.Row>
365 <Table.Cell>
366 Typo tolerance
367 </Table.Cell>
368 <Table.Cell>
369
370 Supported and configurable per index and query, with word-length thresholds and field exemptions.
371
372 </Table.Cell>
373 <Table.Cell>
374 Supported and configurable per index and per attribute.
375 </Table.Cell>
376 </Table.Row>
377 <Table.Row>
378 <Table.Cell>
379 Filters
380 </Table.Cell>
381 <Table.Cell>
382
383 Every operator the Search Module offers, including `$or`, `$not`, and several operators on one field.
384
385 </Table.Cell>
386 <Table.Cell>
387 A filter syntax with numeric, tag, and facet filters, on attributes you mark as facetable.
388 </Table.Cell>
389 </Table.Row>
390 <Table.Row>
391 <Table.Cell>
392 Synonyms
393 </Table.Cell>
394 <Table.Cell>
395 Not supported. An index that declares them fails at startup.
396 </Table.Cell>
397 <Table.Cell>
398 Supported, with one-way, alternative-form, and placeholder synonyms.
399 </Table.Cell>
400 </Table.Row>
401 <Table.Row>
402 <Table.Cell>
403 Facets
404 </Table.Cell>
405 <Table.Cell>
406 Value and range facets. The hits, the count, and every facet of a query run as one search request.
407 </Table.Cell>
408 <Table.Cell>
409 Facet counts and facet value search on faceted attributes.
410 </Table.Cell>
411 </Table.Row>
412 <Table.Row>
413 <Table.Cell>
414 Highlighting and snippets
415 </Table.Cell>
416 <Table.Cell>
417
418 Supported on searchable fields, with your own markers and optional snippets.
419
420 </Table.Cell>
421 <Table.Cell>
422 Supported, and the front-end libraries render it for you.
423 </Table.Cell>
424 </Table.Row>
425 <Table.Row>
426 <Table.Cell>
427 Sorting by an attribute
428 </Table.Cell>
429 <Table.Cell>
430 Any number of fields, but not alongside a vector query.
431 </Table.Cell>
432 <Table.Cell>
433 Needs a replica index per sort order. A standard replica holds its own copy of the records.
434 </Table.Cell>
435 </Table.Row>
436 <Table.Row>
437 <Table.Cell>
438 Merchandising and rules
439 </Table.Cell>
440 <Table.Cell>
441 Not supported. Order results with your own logic in an API route.
442 </Table.Cell>
443 <Table.Cell>
444 Supported, with rules that pin, boost, or filter results for a given query.
445 </Table.Cell>
446 </Table.Row>
447 <Table.Row>
448 <Table.Cell>
449 Vector and semantic search
450 </Table.Cell>
451 <Table.Cell>
452 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.
453 </Table.Cell>
454 <Table.Cell>
455 Available through Algolia's AI search features, on higher plans.
456 </Table.Cell>
457 </Table.Row>
458 <Table.Row>
459 <Table.Cell>
460 Geo search
461 </Table.Cell>
462 <Table.Cell>
463 Not supported. An index that declares a geo field fails at startup.
464 </Table.Cell>
465 <Table.Cell>
466 Supported, with radius and bounding-box queries.
467 </Table.Cell>
468 </Table.Row>
469 <Table.Row>
470 <Table.Cell>
471 Deep pagination
472 </Table.Cell>
473 <Table.Cell>
474 Up to the 10,000th result.
475 </Table.Cell>
476 <Table.Cell>
477 A configurable pagination limit caps it, and the plan bounds that limit.
478 </Table.Cell>
479 </Table.Row>
480 <Table.Row>
481 <Table.Cell>
482 Analytics and A/B testing
483 </Table.Cell>
484 <Table.Cell>
485
486 Analytics dashboard to track search volumes, queries with no results, and more.
487 </Table.Cell>
488 <Table.Cell>
489 Built in, including click and conversion analytics and index A/B tests.
490 </Table.Cell>
491 </Table.Row>
492 </Table.Body>
493 </Table>
494
495 ---
496
497 ## Storefront Integration
498
499 [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.
500
501 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 Algolia provider.
502
503 ```tsx
504 import {
505 createInstantSearchAdapter,
506 } from "@medusajs/instantsearch-adapter"
507 import { sdk } from "./sdk"
508 import {
509 Configure,
510 InstantSearch,
511 } from "react-instantsearch"
512
513 const PRODUCT_INDEX_NAME = "product"
514
515 export const { searchClient } = createInstantSearchAdapter({
516 sdk,
517 path: "/store/search",
518 })
519
520 const Search = () => (
521 <InstantSearch
522 indexName={PRODUCT_INDEX_NAME}
523 searchClient={searchClient}
524 >
525 <Configure hitsPerPage={12} />
526 {/* Render search widgets */}
527 </InstantSearch>
528 )
529 ```
530
531 Refer to the [InstantSearch Adapter guide](!resources!/instantsearch) for more details and examples of setting up search and filters.
532
533 ---
534
535 ## Admin Dashboard Search
536
537 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.
538
539 This is agnostic across different Search Module Providers, so it works the same for Medusa Search or your custom Algolia provider.
540
541 ---
542
543 ## Comparisons to Other Search Engines
544
545 The following guides compare Medusa Search to other search engines:
546
547 - [All engines compared](../comparison/page.mdx)
548 - [Medusa vs PostgreSQL](../postgres/page.mdx)
549 - [Medusa vs Meilisearch](../meilisearch/page.mdx)