Spec reference: https://hl7.org/fhir/search.html
Bundle of type searchset.
What you get back
Search responses areBundle resources with type: "searchset".
Each match appears in Bundle.entry[].resource. Servers may also include additional
entries with entry.search.mode = "include" when you request _include or
_revinclude.
Where search lives
FHIR defines three common scopes for search:| Scope | What you search | Example |
|---|---|---|
| Type-level | One resource type | GET /fhir/Patient?name=Doe |
| System-level | Multiple types | GET /fhir/_search?_type=Patient,Observation |
| Compartment | Resources related to one compartment instance | GET /fhir/Patient/123/Observation |
Search parameter semantics
AND vs OR
FHIR uses two different “grouping” rules:- Different parameters are AND:
gender=male&active=true - Repeating the same parameter is AND:
name=John&name=Smith - Comma-separated values are OR:
name=John,Smith
Presence testing (:missing)
Most parameter types support checking whether an element is present:
Common search parameter types
FHIR SearchParameters have a declared type. The same parameter name can behave very differently depending on its type.| Type | Example | Notes | ||
|---|---|---|---|---|
string | name=Doe | Text matching; often supports modifiers like :contains and :exact | ||
token | `identifier=http://acme.example/mrn | 123` | “System | code” matching (also used for code, status, tags, etc.) | |
reference | subject=Patient/123 | Matches a reference; supports chaining on many servers | ||
date | birthdate=ge1990-01-01 | Supports prefixes like ge, le, gt, lt | ||
number | value=gt5 | Numeric prefixes like gt, lt, ge, le | ||
quantity | `value-quantity=5 | http://unitsofmeasure.org | mg` | Value + optional unit system and code |
uri | url=http://example.org | URI matching semantics (often exact) |
Which parameters exist for a resource type is defined by
SearchParameter resources and the
FHIR specification for that type (e.g., Patient search parameters differ from Observation).Modifiers and prefixes
String modifiers
Common string modifiers:Date / number prefixes
Common comparison prefixes:Result parameters (how the response is shaped)
These parameters don’t filter “which resources match” — they control the bundle you get back:_count: page size (number of matches per response)_sort: ordering of results_total: whether to include total count (none,estimate,accurate)_summary: return less data (true,text,data,count)_elements: return only certain top-level elements_include/_revinclude: also return related resources
_summary and _elements are about payload size. Servers can implement them differently; treat
them as performance hints, not correctness requirements.Pagination
FHIR pagination is server-controlled: the server returnsBundle.link URLs (e.g. next),
and clients should follow those URLs rather than constructing their own paging logic.
At minimum you should expect a self link, and possibly next, prev, first, and last.
POST-based search (_search)
Search parameters can be sent via POST as form-urlencoded data (useful when URLs get long):
Try it
1
Search a type (no filters)
2
Add one filter
3
Let the server tell you what’s supported
The CapabilityStatement lists supported search parameters per type: