Order healthcare search results

By default, when yousearch healthcare data, the search results are returned inreverse chronological order.When you search over the following FHIR resource types that contain unstructured text, you canorder your search results according to their relevance to your query:

  • Composition
  • DiagnosticReport
  • DocumentReference

Example scenario

Suppose that you're searching for the keywordinsulin for a given patient and you've filtered the results to the resourcesthat contain unstructured text. Among other results, you receive the followingdocuments:

  • Result 1: A DocumentReference resource, dated 24 April, 2024, that containsnotes about the patient's "HbA1c" levels.
  • Result 2: A DiagnosticReport resource, dated 11 January, 2024, that containsnotes about the "insulin regimen" that the patient must follow.

By default, Result 1 is shown higher in the results because it is a newerdocument, but when you order by relevance, Result 2 shows up higher in theresults. This is because it is more relevant to the search queryinsulin.

Order your healthcare search results

To order your search results according to relevance, complete the followingsteps:

Console

  1. In the Google Cloud console, go to theAI Applications page.

    AI Applications

  2. Select the healthcare search app that you want to query.

  3. In the navigation menu, clickPreview.

  4. In thePatient ID field, enter the ID of the patient whose datayou want to query. Patient IDs are case-sensitive.

  5. PressEnter or clickPreview to submit the patient ID.

  6. In theSearch here search bar, enter your query.

    If you enabled autocomplete, you see a list of autocomplete suggestions belowthe search bar as you type.

  7. PressEnter to submit the query.

    • The search results are displayed in paginated tables that are categorizedbased on their FHIR resource type.
    • By default, the search results for all FHIR resource types are displayed inreverse chronological order.
  8. For the Composition, the DocumentReference, and the DiagnosticReportresources, click theSort: Reverse Chronological filter and selectRelevance from the list. The results for these resources are then orderedaccording to relevance.

REST

To order your search results according to relevance, modify yoursearch request in the following way:

  • Add thefilter field to your request to limitthe search results to only those FHIR resources that contain unstructured text: Composition, DiagnosticReport, and DocumentReference.
  • Add theorderBy field to your search request and set its value to_RELEVANCE to get search responses that are sorted according to theirrelevance.
  1. Send the search request.

    curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \  -H "Content-Type: application/json" \  "https://us-discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/us/collections/default_collection/engines/APP_ID/servingConfigs/default_search:search" \  -d '{"query": "KEYWORD_QUERY","filter": "patient_id: ANY(\"PATIENT_ID\") AND resource_type: ANY(\"Composition\", \"DiagnosticReport\", \"DocumentReference\")","orderBy": "_RELEVANCE"}'

    Replace the following:

    • PROJECT_ID: the ID of your Google Cloud project.
    • APP_ID: the ID of the Vertex AI Search app that youwant to query.
    • KEYWORD_QUERY: the keyword that you want to search across the patientclinical data for the filtered patient, such as "diabetes" or "a1c".
    • PATIENT_ID: the resource ID of the patient whose data you want to search.

    You should receive a JSON response that contains itemized search resultslisted in the order of their relevance.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.