Raw
1 import { Note, Table } from "docs-ui"
2
3 export const metadata = {
4 title: `Medusa Search vs PostgreSQL`,
5 keywords: [
6 "search",
7 "medusa search",
8 "postgres",
9 "postgresql",
10 "comparison",
11 "search provider",
12 ],
13 }
14
15 # {metadata.title}
16
17 This guide compares Medusa Search and the PostgreSQL Search Module Provider to help you decide which one to use for your Medusa project.
18
19 ## What is Medusa Search?
20
21 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.
22
23 ---
24
25 ## What is the PostgreSQL Provider?
26
27 The [PostgreSQL Search Module Provider](!resources!/infrastructure-modules/search/providers/postgres) ships with Medusa and stores your search indexes as tables in the database your Medusa application already uses. It needs no external service, and Medusa registers it by default in local development.
28
29 ---
30
31 ## Comparison Summary
32
33 <Table>
34 <Table.Header>
35 <Table.Row>
36 <Table.HeaderCell>
37 Concern
38 </Table.HeaderCell>
39 <Table.HeaderCell>
40 Medusa Search
41 </Table.HeaderCell>
42 <Table.HeaderCell>
43 PostgreSQL
44 </Table.HeaderCell>
45 </Table.Row>
46 </Table.Header>
47 <Table.Body>
48 <Table.Row>
49 <Table.Cell>
50
51 [Setup](#setup-and-infrastructure)
52
53 </Table.Cell>
54 <Table.Cell>
55 Medusa registers and configures it for every Cloud environment.
56 </Table.Cell>
57 <Table.Cell>
58
59 Registered by default locally. Can also be used in production, but requires manual registration and configuration.
60
61 </Table.Cell>
62 </Table.Row>
63 <Table.Row>
64 <Table.Cell>
65
66 [Local development](#local-development)
67
68 </Table.Cell>
69 <Table.Cell>
70 Either use the PostgreSQL provider locally, or connect to the environment's Medusa Search endpoint.
71 </Table.Cell>
72 <Table.Cell>
73 The default provider locally, so search works with no extra service.
74 </Table.Cell>
75 </Table.Row>
76 <Table.Row>
77 <Table.Cell>
78
79 [Per-environment isolation](#environments-and-previews)
80
81 </Table.Cell>
82 <Table.Cell>
83 Medusa manages one set of indexes per environment for you.
84 </Table.Cell>
85 <Table.Cell>
86 Indexes are tables, so they travel with the environment's database.
87 </Table.Cell>
88 </Table.Row>
89 <Table.Row>
90 <Table.Cell>
91
92 [What you pay for](#cost-and-packaging)
93
94 </Table.Cell>
95 <Table.Cell>
96 No separate subscription. Your plan includes a monthly allowance of search requests, and anything above it is Flex Usage.
97 </Table.Cell>
98 <Table.Cell>
99 Your database's own resources, since search competes with your transactional workload.
100 </Table.Cell>
101 </Table.Row>
102 <Table.Row>
103 <Table.Cell>
104
105 [Full-text search](#search-capabilities)
106
107 </Table.Cell>
108 <Table.Cell>
109 Relevance scales with the weight you set on each field.
110 </Table.Cell>
111 <Table.Cell>
112 Weights collapse onto four relevance tiers.
113 </Table.Cell>
114 </Table.Row>
115 <Table.Row>
116 <Table.Cell>
117
118 [Typo tolerance](#search-option-support)
119
120 </Table.Cell>
121 <Table.Cell>
122 Supported, through fuzzy matching that ranks below exact matches.
123 </Table.Cell>
124 <Table.Cell>
125 Supported, through trigram word similarity.
126 </Table.Cell>
127 </Table.Row>
128 <Table.Row>
129 <Table.Cell>
130
131 [Filters](#filter-support)
132
133 </Table.Cell>
134 <Table.Cell>
135
136 Every operator, including `$or`, `$not`, and several operators on one field.
137
138 </Table.Cell>
139 <Table.Cell>
140
141 Every operator, including `$or`, `$not`, and several operators on one field.
142
143 </Table.Cell>
144 </Table.Row>
145 <Table.Row>
146 <Table.Cell>
147
148 [Facets](#facet-support)
149
150 </Table.Cell>
151 <Table.Cell>
152 Value, range, and stats. The hits, the count, and every facet of a query run as one search request.
153 </Table.Cell>
154 <Table.Cell>
155 Value, range, and stats.
156 </Table.Cell>
157 </Table.Row>
158 <Table.Row>
159 <Table.Cell>
160
161 [Sorting](#pagination-and-sorting-support)
162
163 </Table.Cell>
164 <Table.Cell>
165 Any number of fields, but not alongside a vector query.
166 </Table.Cell>
167 <Table.Cell>
168 Any number of fields, alongside a text query.
169 </Table.Cell>
170 </Table.Row>
171 <Table.Row>
172 <Table.Cell>
173
174 [Vector and hybrid search](#search-option-support)
175
176 </Table.Cell>
177 <Table.Cell>
178
179 Supported on the Scale and Enterprise plans, including a hybrid of text and vector search. Medusa Search can also create the embeddings, on the Enterprise plan.
180
181 </Table.Cell>
182 <Table.Cell>
183
184 Not supported. The provider ignores a vector field in the index definition and rejects a vector query.
185
186 </Table.Cell>
187 </Table.Row>
188 <Table.Row>
189 <Table.Cell>
190
191 [Deep pagination](#pagination-and-sorting-support)
192
193 </Table.Cell>
194 <Table.Cell>
195 Up to the 10,000th result, which is well past what a storefront paginates through.
196 </Table.Cell>
197 <Table.Cell>
198 No limit, though a deep offset gets slower as the query scans and discards more rows.
199 </Table.Cell>
200 </Table.Row>
201 <Table.Row>
202 <Table.Cell>
203
204 [Storefront querying](#storefront-integration)
205
206 </Table.Cell>
207 <Table.Cell>
208 Supported by Medusa's InstantSearch adapter.
209 </Table.Cell>
210 <Table.Cell>
211 Supported by Medusa's InstantSearch adapter, except for highlighting.
212 </Table.Cell>
213 </Table.Row>
214 <Table.Row>
215 <Table.Cell>
216
217 [Admin dashboard search](#admin-dashboard-search)
218
219 </Table.Cell>
220 <Table.Cell>
221 Uses your indexes automatically.
222 </Table.Cell>
223 <Table.Cell>
224 Uses your indexes automatically, and works in local development.
225 </Table.Cell>
226 </Table.Row>
227 </Table.Body>
228 </Table>
229
230 ---
231
232 ## Setup and Infrastructure
233
234 ### Medusa Search
235
236 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.
237
238 ### PostgreSQL
239
240 The PostgreSQL provider needs no external service, since it indexes into the database your Medusa application already uses. It may need additional setup based on your use case, such as configuring languages other than English in your database.
241
242 You must also make sure that your database can support the additional load imposed by the search indexes and queries. The index lives beside your orders and your products, so a heavy search workload competes with checkout for the same CPU, memory, and disk. Medusa Search moves that load off your database entirely.
243
244 ### Local Development
245
246 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).
247
248 ---
249
250 ## Integration with Medusa
251
252 Both providers ship with Medusa and implement the same [Search Module Provider](!resources!/infrastructure-modules/search/providers) interface, so there's no integration code to write for either one.
253
254 ---
255
256 ## Environments and Previews
257
258 ### Medusa Search
259
260 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.
261
262 ### PostgreSQL
263
264 PostgreSQL indexes need no separate arrangement, since they're tables in the database. An environment's indexes travel with its database, so a database copy brings a filled index with it and a fresh database starts with an empty one.
265
266 ---
267
268 ## Cost and Packaging
269
270 Neither provider bills separately, so compare where the load lands instead:
271
272 <Table>
273 <Table.Header>
274 <Table.Row>
275 <Table.HeaderCell>
276 Provider
277 </Table.HeaderCell>
278 <Table.HeaderCell>
279 What you pay for
280 </Table.HeaderCell>
281 <Table.HeaderCell>
282 What drives the cost up
283 </Table.HeaderCell>
284 </Table.Row>
285 </Table.Header>
286 <Table.Body>
287 <Table.Row>
288 <Table.Cell>
289 Medusa Search
290 </Table.Cell>
291 <Table.Cell>
292
293 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.
294
295 </Table.Cell>
296 <Table.Cell>
297
298 Search requests beyond your plan's allowance, which count as [Flex Usage](../../usage/page.mdx#what-is-flex-usage).
299
300 </Table.Cell>
301 </Table.Row>
302 <Table.Row>
303 <Table.Cell>
304 PostgreSQL
305 </Table.Cell>
306 <Table.Cell>
307
308 Nothing on top of the [database](../../database/page.mdx) you already run, since the indexes are tables in it.
309
310 </Table.Cell>
311 <Table.Cell>
312 Index size and search traffic, since both raise the database tier you need. Search also competes with checkout for the same resources.
313 </Table.Cell>
314 </Table.Row>
315 </Table.Body>
316 </Table>
317
318 ### Other Cloud Usage PostgreSQL Affects
319
320 Using the PostgreSQL provider for Search on Cloud can drive up the costs of the following Cloud usage metrics:
321
322 - **Database Storage** grows with every index, since each one is a table in your database. A large catalog with several indexes adds gigabytes to the metric you're billed on, on top of your commerce data.
323 - **Compute** covers the indexing work, since the seed and the event handlers that fill an index run in your Medusa application.
324
325 Refer to [Usage](../../usage/page.mdx) on how to monitor these metrics.
326
327 ---
328
329 ## Index Definition Support
330
331 The Search Module provides the interface to define different types of fields in search indexes, but it's the responsibility of each provider to actually support them. The following table summarizes how each provider handles the different types of fields and settings.
332
333 A field a provider can't store doesn't make the whole index fail. The PostgreSQL provider logs a warning and creates the index without the vector fields in your definition, so one definition works on both providers.
334
335 <Table>
336 <Table.Header>
337 <Table.Row>
338 <Table.HeaderCell>
339 Index Definition
340 </Table.HeaderCell>
341 <Table.HeaderCell>
342 Medusa Search
343 </Table.HeaderCell>
344 <Table.HeaderCell>
345 PostgreSQL
346 </Table.HeaderCell>
347 </Table.Row>
348 </Table.Header>
349 <Table.Body>
350 <Table.Row>
351 <Table.Cell>
352
353 A [`search.vector()`](!resources!/infrastructure-modules/search/index-definitions/fields#searchvector) field
354
355 </Table.Cell>
356 <Table.Cell>
357
358 Holds the embedding as a fixed-width float vector. Fails at startup if the field is an array or declares no positive `dimensions`.
359
360 </Table.Cell>
361 <Table.Cell>
362
363 Ignores the field and logs a warning, since the provider has nowhere to store an embedding. It creates the rest of the index, so the same definition stays usable on both providers.
364
365 </Table.Cell>
366 </Table.Row>
367 <Table.Row>
368 <Table.Cell>
369
370 A [`search.geo()`](!resources!/infrastructure-modules/search/index-definitions/fields#searchgeo) field
371
372 </Table.Cell>
373 <Table.Cell>
374 Fails at startup.
375 </Table.Cell>
376 <Table.Cell>
377 Fails at startup.
378 </Table.Cell>
379 </Table.Row>
380 <Table.Row>
381 <Table.Cell>
382
383 `settings.synonyms` or `settings.stop_words`
384
385 </Table.Cell>
386 <Table.Cell>
387 Fails at startup.
388 </Table.Cell>
389 <Table.Cell>
390 Ignored.
391 </Table.Cell>
392 </Table.Row>
393 <Table.Row>
394 <Table.Cell>
395
396 `settings.distinct_attribute`
397
398 </Table.Cell>
399 <Table.Cell>
400
401 Applied to every query that doesn't pass its own `distinct`.
402
403 </Table.Cell>
404 <Table.Cell>
405
406 Ignored. Pass `distinct` per query instead.
407
408 </Table.Cell>
409 </Table.Row>
410 <Table.Row>
411 <Table.Cell>
412
413 `settings.provider_options` and [`providerOptions()`](!resources!/infrastructure-modules/search/index-definitions/modifiers#provideroptions)
414
415 </Table.Cell>
416 <Table.Cell>
417 Reads its own entry on the index, on a field, and on a query.
418 </Table.Cell>
419 <Table.Cell>
420 Ignored. The provider reads no entry of its own.
421 </Table.Cell>
422 </Table.Row>
423 <Table.Row>
424 <Table.Cell>
425 A document whose primary key is longer than 64 bytes
426 </Table.Cell>
427 <Table.Cell>
428 Throws when the document is written, which fails the seed or the write.
429 </Table.Cell>
430 <Table.Cell>
431 Written as-is.
432 </Table.Cell>
433 </Table.Row>
434 </Table.Body>
435 </Table>
436
437 ---
438
439 ## Indexing and Synchronization
440
441 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 PostgreSQL.
442
443 What differs is how each provider implements the logic to support indexing and synchronization. Since Medusa implements both providers, it ensures consistent behavior from the perspective of the Search Module. The main difference is where the index resides and how it is managed.
444
445 <Table>
446 <Table.Header>
447 <Table.Row>
448 <Table.HeaderCell>
449 Behavior
450 </Table.HeaderCell>
451 <Table.HeaderCell>
452 Medusa Search
453 </Table.HeaderCell>
454 <Table.HeaderCell>
455 PostgreSQL
456 </Table.HeaderCell>
457 </Table.Row>
458 </Table.Header>
459 <Table.Body>
460 <Table.Row>
461 <Table.Cell>
462 Where the index lives
463 </Table.Cell>
464 <Table.Cell>
465 The Medusa Search service, scoped to the environment handle you configure.
466 </Table.Cell>
467 <Table.Cell>
468 A table per index in your PostgreSQL database, tracked in a catalog table.
469 </Table.Cell>
470 </Table.Row>
471 <Table.Row>
472 <Table.Cell>
473 What a new index version is built as
474 </Table.Cell>
475 <Table.Cell>
476 A separate namespace in the Medusa Search service, which the module writes to until it makes that version active.
477 </Table.Cell>
478 <Table.Cell>
479 A separate table in your database, which the module writes to until it makes that version active.
480 </Table.Cell>
481 </Table.Row>
482 <Table.Row>
483 <Table.Cell>
484 How a batch of documents is written
485 </Table.Cell>
486 <Table.Cell>
487 Split into requests of at most 480 MiB. A single document above that limit throws.
488 </Table.Cell>
489 <Table.Cell>
490 200 documents per statement.
491 </Table.Cell>
492 </Table.Row>
493 </Table.Body>
494 </Table>
495
496 ---
497
498 ## Search Capabilities
499
500 A provider that can't serve part of a request rejects it instead of answering differently. The tables below say when that rejection happens:
501
502 - **Fails at startup**: the provider throws while the Search Module creates or migrates the index, so your application doesn't boot or `db:migrate` fails.
503 - **Fails per query**: the provider throws for the requests that use the feature. Other requests are unaffected.
504 - **Ignored**: the provider accepts the request and doesn't act on the feature, so results look as if you never passed it.
505
506 Refer to [`searchable()`](!resources!/infrastructure-modules/search/index-definitions/modifiers#searchable) for how each provider reads a field's weight.
507
508 ### Search Option Support
509
510 What each provider does with the [search options](!docs!/learn/fundamentals/query/search#search-options) of a `query.search` call.
511
512 <Table>
513 <Table.Header>
514 <Table.Row>
515 <Table.HeaderCell>
516 Option
517 </Table.HeaderCell>
518 <Table.HeaderCell>
519 Medusa Search
520 </Table.HeaderCell>
521 <Table.HeaderCell>
522 PostgreSQL
523 </Table.HeaderCell>
524 </Table.Row>
525 </Table.Header>
526 <Table.Body>
527 <Table.Row>
528 <Table.Cell>
529
530 `vector`
531
532 </Table.Cell>
533 <Table.Cell>
534
535 Runs a similarity search on the embedding you pass as `value`, or on the text you pass as `query` when the field declares `embed`. Blends it with a `q` filter by `semantic_ratio`. Fails per query if the search also orders by a field.
536
537 </Table.Cell>
538 <Table.Cell>
539
540 Fails per query.
541
542 </Table.Cell>
543 </Table.Row>
544 <Table.Row>
545 <Table.Cell>
546
547 `typo_tolerance`
548
549 </Table.Cell>
550 <Table.Cell>
551
552 Widens the match with fuzzy matching on every searchable field that carries a fuzzy index, ranking those hits below the exact ones. Ignored when the query passes no `q` filter, or when no searched field has a fuzzy index.
553
554 </Table.Cell>
555 <Table.Cell>
556 Widens the match with trigram word similarity.
557 </Table.Cell>
558 </Table.Row>
559 <Table.Row>
560 <Table.Cell>
561
562 `min_score`
563
564 </Table.Cell>
565 <Table.Cell>
566 Fails per query.
567 </Table.Cell>
568 <Table.Cell>
569 Discards hits below the threshold before paginating, so the count stays truthful.
570 </Table.Cell>
571 </Table.Row>
572 <Table.Row>
573 <Table.Cell>
574
575 `match_strategy`
576
577 </Table.Cell>
578 <Table.Cell>
579
580 Serves `all`, `any`, and `last`.
581
582 </Table.Cell>
583 <Table.Cell>
584
585 Serves `all` and `any`. Fails per query for `last`.
586
587 </Table.Cell>
588 </Table.Row>
589 <Table.Row>
590 <Table.Cell>
591
592 `count: "none"`
593
594 </Table.Cell>
595 <Table.Cell>
596
597 Skips the count query and returns `null` as the count.
598
599 </Table.Cell>
600 <Table.Cell>
601
602 Skips the count query and returns `null` as the count.
603
604 </Table.Cell>
605 </Table.Row>
606 <Table.Row>
607 <Table.Cell>
608
609 `distinct`
610
611 </Table.Cell>
612 <Table.Cell>
613 Keeps one hit per value.
614 </Table.Cell>
615 <Table.Cell>
616 Keeps one hit per value, picked by the query's order. Fails per query on an unknown, array, or vector field.
617 </Table.Cell>
618 </Table.Row>
619 <Table.Row>
620 <Table.Cell>
621
622 [`highlight`](!docs!/learn/fundamentals/query/search#highlighting)
623
624 </Table.Cell>
625 <Table.Cell>
626
627 Returns a fragment per highlighted field. Ignored when the query passes no `q` filter, and for a field that isn't searchable.
628
629 </Table.Cell>
630 <Table.Cell>
631 Fails per query. The provider doesn't implement highlighting.
632 </Table.Cell>
633 </Table.Row>
634 <Table.Row>
635 <Table.Cell>
636
637 `locales`
638
639 </Table.Cell>
640 <Table.Cell>
641 Fails per query. Configure the language on the index's fields instead.
642 </Table.Cell>
643 <Table.Cell>
644
645 Fails per query. Set `language` in the provider options instead.
646
647 </Table.Cell>
648 </Table.Row>
649 </Table.Body>
650 </Table>
651
652 ### Pagination and Sorting Support
653
654 <Table>
655 <Table.Header>
656 <Table.Row>
657 <Table.HeaderCell>
658 Request
659 </Table.HeaderCell>
660 <Table.HeaderCell>
661 Medusa Search
662 </Table.HeaderCell>
663 <Table.HeaderCell>
664 PostgreSQL
665 </Table.HeaderCell>
666 </Table.Row>
667 </Table.Header>
668 <Table.Body>
669 <Table.Row>
670 <Table.Cell>
671
672 [Ordering](!docs!/learn/fundamentals/query/search#apply-pagination) by more than one field
673
674 </Table.Cell>
675 <Table.Cell>
676 Sends every key to the service in the order you list them.
677 </Table.Cell>
678 <Table.Cell>
679 Applies every key in the order you list them.
680 </Table.Cell>
681 </Table.Row>
682 <Table.Row>
683 <Table.Cell>
684 Ordering by a field alongside a text query
685 </Table.Cell>
686 <Table.Cell>
687 Orders by the field, which replaces relevance ranking rather than refining it. Alongside a vector query it fails per query instead.
688 </Table.Cell>
689 <Table.Cell>
690
691 Orders by the field. A hybrid text and vector search fails per query, since its results are rank-fused and only `_score` can order them.
692
693 </Table.Cell>
694 </Table.Row>
695 <Table.Row>
696 <Table.Cell>
697 Ordering by an array field
698 </Table.Cell>
699 <Table.Cell>
700 Sends the field to the service as a rank key without checking it first.
701 </Table.Cell>
702 <Table.Cell>
703 Fails per query.
704 </Table.Cell>
705 </Table.Row>
706 <Table.Row>
707 <Table.Cell>
708 A page beyond the 10,000th result
709 </Table.Cell>
710 <Table.Cell>
711
712 Fails per query when `skip` plus `take` is above 10,000.
713
714 </Table.Cell>
715 <Table.Cell>
716 Served.
717 </Table.Cell>
718 </Table.Row>
719 <Table.Row>
720 <Table.Cell>
721
722 Paginating with `pagination.cursor`
723
724 </Table.Cell>
725 <Table.Cell>
726
727 Fails per query. Paginate with `skip` and `take`.
728
729 </Table.Cell>
730 <Table.Cell>
731
732 Fails per query. Paginate with `skip` and `take`.
733
734 </Table.Cell>
735 </Table.Row>
736 </Table.Body>
737 </Table>
738
739 ### Filter Support
740
741 What each provider does with a [filter](!docs!/learn/fundamentals/query/search#apply-filters) tree. Refer to [Filter Operators](!docs!/learn/fundamentals/query/search#filter-operators) for what each operator means.
742
743 <Table>
744 <Table.Header>
745 <Table.Row>
746 <Table.HeaderCell>
747 Filter
748 </Table.HeaderCell>
749 <Table.HeaderCell>
750 Medusa Search
751 </Table.HeaderCell>
752 <Table.HeaderCell>
753 PostgreSQL
754 </Table.HeaderCell>
755 </Table.Row>
756 </Table.Header>
757 <Table.Body>
758 <Table.Row>
759 <Table.Cell>
760
761 `$or` or `$not`
762
763 </Table.Cell>
764 <Table.Cell>
765 Compiled into the query.
766 </Table.Cell>
767 <Table.Cell>
768 Compiled into the query.
769 </Table.Cell>
770 </Table.Row>
771 <Table.Row>
772 <Table.Cell>
773
774 Two operators on one field, such as `$gt` with `$ne`
775
776 </Table.Cell>
777 <Table.Cell>
778
779 Both applied, combined with `AND`.
780
781 </Table.Cell>
782 <Table.Cell>
783
784 Both applied, combined with `AND`.
785
786 </Table.Cell>
787 </Table.Row>
788 <Table.Row>
789 <Table.Cell>
790
791 `$exists`
792
793 </Table.Cell>
794 <Table.Cell>
795 Compiled into a comparison against no value.
796 </Table.Cell>
797 <Table.Cell>
798 Compiled into a presence check.
799 </Table.Cell>
800 </Table.Row>
801 <Table.Row>
802 <Table.Cell>
803
804 `$prefix` or `$like`
805
806 </Table.Cell>
807 <Table.Cell>
808
809 Compiled into a glob match, with `%` and `_` translated for `$like`.
810
811 </Table.Cell>
812 <Table.Cell>
813 Compiled into a pattern match. Fails per query on an array field.
814 </Table.Cell>
815 </Table.Row>
816 <Table.Row>
817 <Table.Cell>
818
819 `$ne` or `$nin` on a numeric, boolean, or array field
820
821 </Table.Cell>
822 <Table.Cell>
823 Compiled into a negated match.
824 </Table.Cell>
825 <Table.Cell>
826 Compiled into a negated match.
827 </Table.Cell>
828 </Table.Row>
829 <Table.Row>
830 <Table.Cell>
831
832 Several values for one numeric or boolean field, with `$in` or a plain array
833
834 </Table.Cell>
835 <Table.Cell>
836 Matches any of the values.
837 </Table.Cell>
838 <Table.Cell>
839 Matches any of the values.
840 </Table.Cell>
841 </Table.Row>
842 </Table.Body>
843 </Table>
844
845 ### Facet Support
846
847 What each provider does with the [facets](!docs!/learn/fundamentals/query/search#facets) a query requests.
848
849 <Table>
850 <Table.Header>
851 <Table.Row>
852 <Table.HeaderCell>
853 Request
854 </Table.HeaderCell>
855 <Table.HeaderCell>
856 Medusa Search
857 </Table.HeaderCell>
858 <Table.HeaderCell>
859 PostgreSQL
860 </Table.HeaderCell>
861 </Table.Row>
862 </Table.Header>
863 <Table.Body>
864 <Table.Row>
865 <Table.Cell>
866
867 A `stats` facet
868
869 </Table.Cell>
870 <Table.Cell>
871 Returns the minimum, maximum, sum, and count, but no average. Costs one query per aggregate, so four for a numeric field and three for a date. Fails per query on a field that isn't numeric, or on an array field.
872 </Table.Cell>
873 <Table.Cell>
874 Returns the minimum, maximum, average, sum, and count. Fails per query on a field that isn't numeric.
875 </Table.Cell>
876 </Table.Row>
877 <Table.Row>
878 <Table.Cell>
879
880 A `range` facet
881
882 </Table.Cell>
883 <Table.Cell>
884 Counts each bucket with its own query, so a facet with five buckets costs five queries.
885 </Table.Cell>
886 <Table.Cell>
887 Counts each bucket in one query. Fails per query on a field that isn't numeric.
888 </Table.Cell>
889 </Table.Row>
890 <Table.Row>
891 <Table.Cell>
892 Many facets in one query
893 </Table.Cell>
894 <Table.Cell>
895 Batches the hits, the count, and every facet query into one request, and fails per query above 16 of them.
896 </Table.Cell>
897 <Table.Cell>
898 Runs one extra query per facet.
899 </Table.Cell>
900 </Table.Row>
901 <Table.Row>
902 <Table.Cell>
903
904 A facet value `sort` or `limit`
905
906 </Table.Cell>
907 <Table.Cell>
908 Applied by the provider after it reads every group back.
909 </Table.Cell>
910 <Table.Cell>
911 Applied by the query that computes the facet.
912 </Table.Cell>
913 </Table.Row>
914 <Table.Row>
915 <Table.Cell>
916
917 [Disjunctive facets](!docs!/learn/fundamentals/query/search#disjunctive-facets)
918
919 </Table.Cell>
920 <Table.Cell>
921 Runs the fan-out as one request, since the provider accepts more than one query per request.
922 </Table.Cell>
923 <Table.Cell>
924 Runs the fan-out as one request, since the provider accepts more than one query per request.
925 </Table.Cell>
926 </Table.Row>
927 </Table.Body>
928 </Table>
929
930 ---
931
932 ## Storefront Integration
933
934 [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.
935
936 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 the PostgreSQL provider.
937
938 ```tsx
939 import {
940 createInstantSearchAdapter,
941 } from "@medusajs/instantsearch-adapter"
942 import { sdk } from "./sdk"
943 import {
944 Configure,
945 InstantSearch,
946 } from "react-instantsearch"
947
948 const PRODUCT_INDEX_NAME = "product"
949
950 export const { searchClient } = createInstantSearchAdapter({
951 sdk,
952 path: "/store/search",
953 })
954
955 const Search = () => (
956 <InstantSearch
957 indexName={PRODUCT_INDEX_NAME}
958 searchClient={searchClient}
959 >
960 <Configure hitsPerPage={12} />
961 {/* Render search widgets */}
962 </InstantSearch>
963 )
964 ```
965
966 So, the same storefront code runs against the PostgreSQL provider locally and Medusa Search on Cloud. The difference is which options each provider rejects, which is why a storefront that works locally can fail on Cloud. Build against the narrower of the two, or gate the options you pass on the provider in use.
967
968 Refer to the [InstantSearch Adapter guide](!resources!/instantsearch) for more details and examples of setting up search and filters.
969
970 ---
971
972 ## Admin Dashboard Search
973
974 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.
975
976 This is agnostic across different Search Module Providers, so it works the same for both providers. The PostgreSQL provider has one advantage here: it works locally, so you see the indexed admin search behavior in development rather than after a deployment.
977
978 ---
979
980 ## Comparisons to Other Search Engines
981
982 The following guides compare Medusa Search to other search engines:
983
984 - [All engines compared](../comparison/page.mdx)
985 - [Medusa vs Algolia](../algolia/page.mdx)
986 - [Medusa vs Meilisearch](../meilisearch/page.mdx)