HAPI FHIR search support and known limitations

The HAPI FHIR JPA server covers most FHIR search, but it has known gaps in _has chaining, Location near searches, _filter and a few non-standard parameters. This page explains what to test and plan for before clients depend on search.

On this page

HAPI FHIR search support: what teams need to know before go-live

If your client applications will query a HAPI FHIR JPA server, most standard FHIR searches will work, but a few do not match the specification. The JPA server does not support chains within _has, implements Location near as a bounding box rather than a radius search, only partially implements _filter, and offers the non-standard _pid and _compartmentLastUpdated parameters. Each of these can break a client query that was written against the spec, so the search test plan should cover them before go-live. The JPA server is HAPI FHIR's database-backed RESTful FHIR server, and its documentation covers FHIR DSTU2, DSTU3, R4, R4B and R5, so the FHIR version your clients target determines which search rules you test against. Confirm the version in your target release with the HAPI FHIR JPA server introduction before you finalize the client contract.

Search gaps matter most in three places: client apps that assume spec behavior, reporting that relies on specific parameters, and integrations built against another FHIR vendor's search results. A map-based clinic finder that expects a radius around a point will return different results with a box, and a client that uses _has chains will receive an error or no matches. Ask each client team to list every search parameter, modifier and chain they use, then mark which ones fall into the unsupported or partial categories. Non-standard parameters such as _pid are useful for internal tooling, but any client that depends on them ties you to HAPI behavior and makes a later move harder.

Search results are also cached. HAPI FHIR caches search results for one minute by default. Clients can bypass the cache per request with a Cache-Control header, and the starter's reuse_cached_search_results_millis setting controls the window. Test whether a write followed by a search returns fresh data within that window, because a clinical app that shows a result just saved can look wrong. Decide with your application owners whether the default is acceptable, whether those clients should send the header, or whether the setting should change, and document the decision in your go-live checklist.

Where HAPI FHIR search differs from the specification

This table compares each known gap in the HAPI FHIR JPA server's search behavior with what the FHIR specification or a typical client expects, and the likely effect on an integration. Read each row as a question to answer before go-live: confirm exact behavior against the search documentation for your version, then decide whether a client workaround or a server change is needed.

GapWhat the server doesWhat the client or spec expectsLikely impact on a client or integration
Chains within _hasDoes not support chained parameters inside a _has clauseReverse chaining with _has can contain nested chained parametersQueries that combine _has with a chain fail or return unexpected results, so split them into several requests
Location near as a boxImplements the near parameter as a bounding box rather than a radiusA radius-based near search around a pointResults cover a rectangular area, so clients may get more or fewer locations than a radius search would return
Partial _filterOnly partially implements the _filter parameterFull _filter expression support as defined in the specificationSome filter expressions are ignored or rejected, so test each filter your application sends against the server
Non-standard _pidOffers a _pid search parameter that is not defined in the core specificationOnly parameters defined by the specification or the server's CapabilityStatementClients written against the spec will not depend on it, but portable code should avoid it and other FHIR servers may not accept it
Non-standard _compartmentLastUpdatedOffers a _compartmentLastUpdated parameter that is not defined in the core specificationOnly parameters defined by the specification or the server's CapabilityStatementChange-tracking code built on it will not work against servers that lack it, so keep it isolated and documented
Search result cachingCaches search results for one minute by defaultResults reflect the current data unless the client asks otherwiseRecently changed data can appear stale in search results; clients can send a Cache-Control header per request, and operators can change reuse_cached_search_results_millis

How each gap breaks client queries

Each gap in the JPA server's search behavior shows up in a different way. A query can return results that look plausible but are incomplete, or a client can assume a standard behavior that the server handles differently. The cards below describe the failure, the query pattern that triggers it, and the test that exposes it before a client team does.

_has chains silently fail

Clients often assume a chained parameter inside _has works the same way it does in a plain search. The JPA server does not support chains within _has, so a query such as a nested reverse include can return an empty or narrower set than the client expects, with no error that points to the cause. Build a test with a known record graph, run the chained _has query, and compare the result count against the expected set. Treat an unexpected empty result as a defect in the client's query until the server behavior is confirmed.

JPA search docs

Near searches return boxes

The server implements Location near as a box rather than a radius search. A client that asks for facilities within a distance will receive every location inside a rectangle, which includes some results outside the radius and can differ near the corners. Clients that display results as nearest-first or apply their own distance cut-off will show the wrong facilities. Test with points placed just outside the intended radius and just inside the box corners, then confirm the client filters the returned set by true distance.

Partial _filter expressions

The _filter parameter is only partially implemented, so some filter expressions apply and others are ignored or handled differently from the specification. A client that sends a filter expecting a narrowed set may receive a superset, and the error is easy to miss when the test data is small. Maintain a list of the filter expressions your clients send, run each against a representation of production data, and compare results with the expected narrowing. Any expression not on the verified list should stay out of production clients.

Paging and cache assumptions

Clients that assume every search reflects the latest data may be wrong, because the JPA server caches search results for one minute by default. A write followed by a search within that window can return stale results, and a paging loop that reads links across requests can see shifting totals. Test a write-then-read sequence and a multi-page walk while data changes. Confirm whether the client sends a Cache-Control header on reads that must be current, and confirm the reuse_cached_search_results_millis value in your deployment.

JPA configuration options

Non-standard parameters in client code

The server offers the non-standard _pid and _compartmentLastUpdated parameters. Clients that use them work against this server but will not port to a server that follows the specification only, and a client library may send them without the team noticing. Search the client code and generated query logs for both parameters, record each use, and decide whether to replace it with a standard query or document it as a server-specific dependency before a migration or upgrade.

Choosing a search strategy by use case

A clinical application that relies on standard R4 search for patient lookup, encounter lists and observation queries usually works within the supported search surface. The gaps described on this page matter less here because clinical apps tend to use direct parameters such as identifier, patient and date, which the server handles. Check first whether any screen depends on a chained search inside _has, a partial _filter expression or a radius-based Location search. If one does, the screen is the place to change, not the server.

  • Standard parameters first: Map each screen to the exact search parameters and modifiers it calls, and confirm each one against the server's CapabilityStatement.
  • Narrower queries: Replace a broad _has chain with two requests, one per resource type, and join the results in the application.
  • Client-side filtering: For a small result set, fetch a bounded page and filter in the application, keeping the page size and the number of requests under control.
  • Cache awareness: Results are cached for one minute by default, so screens that show fresh data after a write should request the bypass the server supports.
  • Non-standard parameters: Avoid building clinical features on _pid or _compartmentLastUpdated unless the team documents them as server-specific.

Before committing, run every search your application uses against a copy of production-like data and record the responses, including paging behavior and result counts.

How to test search before production use

This sequence turns vague confidence in HAPI FHIR search into a tested list of which client queries work, which diverge from the specification, and which need a workaround before go-live. Each step ends with a recorded result you can review.

  1. Pin the version and JDK requirement

    The platform team selects one HAPI FHIR release and records it alongside the JDK it requires. HAPI FHIR 8.2.0 requires JDK 17, so a team pinning that release must confirm its build and runtime images use JDK 17 before anything else is installed. Confirm the exact version you intend to ship against the release notes and the versions documentation, and record the pinned version in your change log. The output is a version and JDK pair that every later test run references.

  2. Deploy the starter on PostgreSQL or SQL Server

    The platform team deploys the JPA server starter in a test environment that matches production, backed by PostgreSQL or Microsoft SQL Server rather than the embedded H2 default. Because the starter does not support MySQL, the database choice must be one of the two production options the starter supports. Confirm the server starts, the schema initializes, and a sample Patient can be created and read back. The output is a reachable test server with a production-like database behind it.

  3. Build a catalogue of client search queries

    Integration engineers and the product owners of each consuming application export the search requests their clients actually send, from gateway logs, client code or recorded sessions. Group them by resource type, parameter, modifier and any chained or reverse-chained expression, and note which ones use _has, Location near searches, _filter, _pid or _compartmentLastUpdated. Mark each query with the business result it must produce. The output is a reviewed list of queries with expected outcomes, owned by a named person.

  4. Run each query against the test server

    The QA or integration team runs every catalogued query against the test server, capturing the full request, the response status, the Bundle returned and any OperationOutcome. Use the same parameter order and encoding the clients use. Run queries with the same data load you expect in production so result counts are meaningful. The output is a stored result set for each query that can be rerun later.

  5. Compare results with expected FHIR behavior

    A clinical informatics lead and an engineer compare each result against the behavior the FHIR specification defines and the outcome recorded in step three. Flag every query that returns an error, an empty Bundle where data exists, a box-based Location result where the client expected a radius, partial _filter behavior, or results that differ from the expected set. The HAPI FHIR JPA search documentation lists the known differences and should be the reference for each flag. The output is a findings list separating supported queries, documented differences and unexpected defects.

  6. Verify the cache setting and Cache-Control bypass

    The platform team confirms how search result caching behaves in the test environment. HAPI FHIR caches search results for one minute by default, and the starter's reuse_cached_search_results_millis setting controls that window. Run a query, change the underlying data, then repeat the query with and without a Cache-Control header that bypasses the cache, and confirm the returned results reflect the change when the bypass is used. Record the configured value of the setting. The output is a documented cache behavior that the client team has accepted or changed.

  7. Decide on workarounds for each gap

    The architecture group decides, for each flagged query, whether to change the client, add a server-side interceptor, reshape the data, or accept the difference with documentation. Each decision names an owner, the risk it carries and the test that proves it. Avoid silently accepting a difference that changes clinical or privacy outcomes. The output is a decision register linked to the findings list.

  8. Retest after every upgrade and configuration change

    Every time the HAPI FHIR version, the JDK, the database or the cache setting changes, the team reruns the full query catalogue and compares the new results with the stored baseline. Review the HAPI FHIR upgrade notes for search-related changes before the rerun. Treat any difference from the baseline as a change that needs sign-off. The output is a passing retest record for each change, kept with the version pin from step one.

Why chained search performance needs its own test plan

Chained searches are a separate risk from unsupported syntax. A chained search that the JPA server accepts will return correct-looking results, so it will not fail a functional smoke test. The risk is that response time grows as the data grows, and the growth depends on the chain, the resource counts on each side of it, and the indexes the database can use. Plan a dedicated performance test for every chained search your applications depend on, separate from the functional tests that confirm the parameter works at all.

Build the test on data that matches your production shape, not a small fixture set. Load realistic volumes of each resource type referenced by the chain, with the same reference distribution you see in production, such as how many Observations point at each Patient. Run the same query at several data sizes so you can see whether response time grows in a straight line or sharply. Record the database and server settings with each run, because the database hardware and the JVM heap will change the result as much as the query does. Ask your vendor or partner to confirm which chain shapes they have tested at your target volume before you rely on them.

The search cache can make a test look faster than production. HAPI FHIR caches search results for one minute by default. Repeated identical queries in a load test may be served from the cache, which hides the true cost of the database work. Send Cache-Control headers in the test client to bypass the cache for measured requests, and also run a separate pass with caching on so you know what users will see. Set the starter's reuse_cached_search_results_millis value to the value you intend to run in production and document it with the results. For the wider tuning work, including bulk loading and the batch job framework, see the HAPI FHIR JPA server search documentation and the performance and scaling group of this pillar.

Security and operational considerations for search

Search is where a HAPI FHIR server most often returns data beyond what a user should see, so access rules, parameter exposure, caching and logging have to be designed together. The cards below cover the components that shape that design and the checks to run before search goes into production.

Search narrowing with authorization

The AuthorizationInterceptor decides which resource types and operations a caller may use, but it does not by itself limit which rows a search returns. Search narrowing interceptors add query constraints so a clinician or tenant only sees matching results. Test each role with real search URLs, including chained and _include searches, because a permitted resource type can still leak related records through a reference. Confirm that the narrowing applies to every search path your clients use.

HAPI security docs

Non-standard parameters as data paths

The non-standard _pid and _compartmentLastUpdated parameters are not part of the FHIR specification, so access rules written around standard search parameters may not cover them. A caller who can use _pid may reach resources by internal identifier, and _compartmentLastUpdated can reveal when records in a compartment changed. Decide whether these parameters are needed, and block or restrict them at the gateway or interceptor layer if they are not. Verify this behavior in your installed version before relying on it.

Cached search results after policy changes

HAPI FHIR caches search results for one minute by default, so a search run just after a consent withdrawal, tenant reassignment or role change can still return cached results. Clients can bypass the cache per request with a Cache-Control header, and the starter's reuse_cached_search_results_millis setting controls the window. Decide whether the default is acceptable for your consent and tenant model, and set the cache window or require no-cache headers for sensitive search paths.

BALP audit logging for searches

BALP is the Basic Audit Log Pattern that HAPI FHIR offers for recording access events, including search requests. Each audit event should identify the user, the search parameters and the resources returned, so a privacy officer can answer who searched for what. Confirm which search events your configuration captures, where the logs are stored, how long they are retained and how they are protected from modification. Test by running a search as a known user and checking the record.

No single security layer

HAPI FHIR states that it does not provide one security layer. It offers building blocks such as authentication interceptors, the AuthorizationInterceptor, consent and search narrowing interceptors, CORS support and BALP audit logging. You must assemble these, connect them to your identity provider, and place a gateway or reverse proxy in front of the server. Document which component enforces each rule, and assign an owner for each gap so that search behavior is reviewed as a whole rather than interceptor by interceptor.

Questions teams ask about HAPI FHIR search

Does HAPI FHIR support standard FHIR search on the JPA server?

Yes, the JPA server implements FHIR search, but not every part of the specification. It covers FHIR DSTU2, DSTU3, R4, R4B and R5, and the gaps are specific: chains within _has are not supported, Location near is implemented as a box rather than a radius, _filter is only partially implemented, and the server offers the non-standard _pid and _compartmentLastUpdated parameters. Your query inventory decides whether any gap matters. Start by listing every search your applications, reports and integrations send, then mark each one as fully supported, partially supported or unsupported before you rely on the server for it. The HAPI FHIR JPA server search documentation is the reference for each parameter.

What does the missing chains within _has support affect in practice?

It affects any client that uses reverse-chained searches to find resources by what points at them. A query that filters one resource type using a condition on another resource that references it through _has, with a chain inside the _has clause, will not work as written. Clinical and reporting queries are the usual exposure, for example finding patients by conditions or observations that reference them. The practical fix is to test each such query, then either rewrite it as two simpler searches joined in client code, use a documented alternative such as a custom search parameter, or move that workload to an analytics pipeline. Confirm the workaround against your HAPI FHIR version before committing to it.

How much effort does a search test plan take, and what drives it?

Effort is driven by the number of distinct queries, the number of resource types they touch, how many parameters and modifiers each query uses, and how many of them fall into the known gap areas. Other drivers are the size of the test dataset, whether results must match an expected set exactly, and whether the team must build fixtures or reuse production-like data under your privacy rules. No duration is given here because it depends on your inventory. Ask any provider for a quote built from your query list, the resource types involved and the test environment they will use, and ask which items are one-time work (test design and fixtures) and which recur (retesting after each HAPI FHIR upgrade).

Can our own team test search support, or do we need a partner?

Your team can test search support if it has FHIR expertise, access to a representative dataset and a non-production server it can load freely. The work is mostly systematic: write expected results for each query, run them against the server, and record differences. A partner adds value when the query inventory is large, when results feed clinical or regulatory decisions and need independent evidence, or when your staff lack time for repeated retesting after upgrades. DeployOpen plans and implements self-hosted platforms in your infrastructure and prepares evidence for compliance assessments, but it does not issue audit reports or certifications. Engagements are fixed-scope and agreed in writing before work starts.

How does search result caching change what our tests see?

HAPI FHIR caches search results for one minute by default, so a repeated query within that window can return an earlier result even after data has changed. Tests that insert or update a resource and then search for it can pass or fail depending on timing unless they bypass the cache. Clients can skip the cache for a single request by sending a Cache-Control header, and the starter's reuse_cached_search_results_millis setting controls the cache window on the server. Your test plan should set the cache window deliberately for test environments, include cache-bypassing requests where freshness matters, and document the setting you ran with so results can be reproduced.

What must our team provide before search testing can start?

Three inputs drive the work. The first is a query inventory: every search pattern in use, including the parameters, modifiers, includes and reverse-chained clauses, with the application or report that sends it. The second is data volumes and shape: resource types, approximate record counts, and the references between them, since search behavior and timing depend on data density. The third is a test environment: a HAPI FHIR JPA server running the version you plan to use, a database matching production (PostgreSQL or Microsoft SQL Server), and a controlled dataset that respects your privacy rules. Ask the provider to confirm each input in writing and to list what they will need from your side in the scope.

Should we rely on the HAPI FHIR search gaps or design around them?

Design around them when a gap sits on a path that clinical, billing or reporting decisions depend on. Possible approaches include splitting queries into supported steps, using custom search parameters where the data model allows, or routing analytical questions to a separate store. Keep the decision recorded: name the gap, the affected queries, the workaround and the owner who rechecks it at each upgrade. Unsupported search is a documentation and testing problem as much as a technical one, so the accepted limitations should appear in your application contracts and runbooks.

Official HAPI FHIR documentation for search

Start with the official documentation before you rely on any search behavior described in this page. The most relevant reference is the HAPI FHIR JPA server search documentation, which describes the search parameters and modifiers the JPA server implements and the places where it departs from the FHIR specification. Read it against the exact release you run, because support for individual parameters can change between versions. The version you deploy is the controlling fact, so record it in your architecture notes before comparing any feature against the documentation.

Next, review the JPA server configuration options page. It covers the server settings that change search results and cost, including the search result caching behavior that affects how quickly new writes appear in results. For the starter distribution, the hapi-fhir-jpaserver-starter README lists the properties you set in application.yaml or as environment variables, and it is the file to check when a Docker, Helm or WAR deployment behaves differently from the defaults you expected. Confirm the property names against the release you install, since the starter and the library can diverge.

Ask your integration team to produce a short list of the search patterns their clients use, then check each one against the documentation for your version. Include chained searches, _has, Location proximity queries, _filter and any use of _pid or _compartmentLastUpdated. Anything not clearly listed as supported should be treated as unverified until a test against your own server confirms the result. Plan this review before go-live, and repeat it at every upgrade, because a search that worked on one release may behave differently on the next.

How DeployOpen scopes and delivers HAPI FHIR search work

DeployOpen treats HAPI FHIR search as a scoped engineering task: first we map which search parameters your clients actually use, then we check each one against the JPA server's documented behavior. The result is a written list of supported searches, workarounds and client changes, agreed before any build starts.

How we scope

  • Inventory the search parameters, chains and _has queries your applications and integrations send today
  • Compare each query with the JPA server's documented differences, including _has chains, Location near, and partial _filter
  • Agree in writing which gaps are accepted, which need a client change, and which need a custom search fix
  • Confirm the server version and JDK version in scope, since both affect which behavior applies
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts

How we build

  • Build a test suite of representative FHIR queries and expected results for your supported search set
  • Tune search result caching for your clients, including the one-minute default and per-request bypass
  • Measure chained search behavior against realistic data volumes in an environment you control
  • Document client-side query patterns that avoid unsupported or slow search forms
  • Review any custom search extension for correctness, security and effect on upgrades

How we hand over

  • Deliver a search support matrix that lists each supported, partial and unsupported parameter by resource type
  • Provide a runbook for the non-standard _pid and _compartmentLastUpdated parameters and how your clients should use them
  • Record the cache settings, their rationale and the commands or configuration keys used to change them
  • Walk your engineering and client teams through the matrix and the test suite before handover
  • Keep all artifacts in your repositories so your team can rerun the tests after each upgrade

How we support

  • Offer ongoing support and upgrade testing for the search behavior as a retainer
  • Retest the search matrix when you plan a HAPI FHIR version change, such as a move to a newer release
  • Review new client queries before they reach production and flag unsupported search forms early
  • Run continuous search regression testing when your organization wants it as part of a retainer
  • Confirm current search capabilities against the HAPI FHIR documentation before each planned upgrade

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.