> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omophub.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Advanced Search

> Perform multi-criteria search across OMOP medical vocabularies with advanced filtering by domain, vocabulary, concept class, and standard status.

## Overview

The advanced search endpoint provides powerful multi-criteria search capabilities across healthcare vocabularies. Use complex queries, filters, and ranking to find the most relevant medical concepts.

> [!NOTE]
>
> **Best for:** Complex search scenarios requiring multiple filters, specific
> vocabularies, or advanced ranking criteria.

> [!WARNING]
>
> **Query Requirements:** Provide a configured whole-query clinical
> abbreviation, a query of at least 3 characters, or at least one selective
> filter (`vocabulary_ids`, `domain_ids`, or `concept_class_ids`). Filter-only
> requests and other 1-2 character queries are accepted only when one of those
> filters is present.

## Endpoint

**POST** `string`

/v1/search/advanced

## Authentication

**Authorization** `string` *required*

Bearer token with your API key

## Request Body

**query** `string`

The search query term

**Example:** `"diabetes mellitus type 2"`

**Validation:** Query must be a configured abbreviation (`COPD`, `CHF`, `MI`,
`T2DM`, `HTN`, or `CKD`) or at least 3 characters long, unless the request
includes a `vocabulary_ids`, `domain_ids`, or `concept_class_ids` value. The
field may be omitted for filter-only searches.

**vocabulary\_ids** `string[]`

Array of vocabulary IDs to search within

**Options:** `SNOMED`, `ICD10CM`, `ICD9CM`, `RxNorm`, `LOINC`, `HCPCS`, etc.

**Default:** All vocabularies

**domain\_ids** `string[]`

Array of domain IDs to filter by

**Options:** `Condition`, `Drug`, `Procedure`, `Measurement`, `Observation`, etc.

**concept\_class\_ids** `string[]`

Array of concept class IDs to filter by

**Examples:** `Clinical Finding`, `Pharmaceutical Substance`, `Procedure`

**standard\_concepts\_only** `boolean` (default: false)

Whether to include only standard (`S`) concepts. When omitted, concepts of
every standard status are eligible.

**include\_invalid** `boolean` (default: true)

Whether to include invalid/deprecated concepts. Set to `false` to return only
currently valid concepts.

**include\_facets** `boolean` (default: true)

Whether to include facet counts in the response. Set to `false` when facet
data is not needed.

**include\_synonyms** `boolean` (default: false)

Include published OMOP synonyms in candidate retrieval and match evidence.

**search\_mode** `string` (default: full\_text)

Lexical retrieval mode. Semantic and hybrid search use their dedicated
endpoints and are not aliases of this option.

**min\_score** `number` (default: 0)

Minimum bounded lexical-evidence score. This threshold is evaluated before
clinical-utility ranking, so it removes weak text matches consistently rather
than excluding an entire Standard, Classification, or non-standard tier.

**sort\_by** `string` (default: relevance)

Result sort. Clinical ranking applies only to `relevance`.

**sort\_order** `string` (default: desc)

Sort direction.

**relationship\_filters** `array`

Require each returned concept to satisfy every relationship filter in the
array. Filters are combined with AND, so every filter is required; there is
no `required` field. Unknown relationship or vocabulary identifiers, and
any field not listed below, return `400`. Vocabulary access policy is always
enforced on the concept at the other end of the relationship, including when
only `target_concept_id` is supplied.

**relationship\_id** `string` *required*

OMOP relationship identifier to require.

**target\_concept\_id** `integer`

Optional concept ID that the relationship must connect to.

**target\_vocabularies** `string[]`

Optional vocabulary IDs (1-20). The concept at the other end of the
relationship must belong to one of them. Combined with `target_concept_id`,
both conditions apply to the same relationship. Restricted vocabularies return
`403` unless your API key is licensed for them.

**direction** `string`

Direction in which to evaluate the relationship. `forward` matches the
returned concept as `concept_id_1`, `reverse` matches it as `concept_id_2`,
and `both` accepts either orientation. Defaults to `forward`.

```json theme={null}
[
  {
    "relationship_id": "Maps to",
    "target_concept_id": 201826,
    "direction": "forward"
  }
]
```

To keep only source concepts that map to SNOMED, for example ICD10CM codes
with a standard SNOMED equivalent:

```json theme={null}
[
  {
    "relationship_id": "Maps to",
    "target_vocabularies": ["SNOMED"]
  }
]
```

**date\_range** `object`

Return concepts valid at any point in this inclusive date range. A concept
matches when its validity interval overlaps the requested interval; it does
not need to start and end within the range. Either bound may be omitted for
an open-ended range.

**date\_range properties**

**start\_date** `string`

Inclusive lower bound in `YYYY-MM-DD` format. Concepts whose
`valid_end_date` is on or after this date match.

**end\_date** `string`

Inclusive upper bound in `YYYY-MM-DD` format. Concepts whose
`valid_start_date` is on or before this date match.

```json theme={null}
{
  "start_date": "2020-01-01",
  "end_date": "2024-12-31"
}
```

**page** `integer` (default: 1)

Page number (1-based indexing)

**page\_size** `integer` (default: 20)

Number of results per page (max: 1000)

## Response

**success** `boolean`

Whether the request was successful

**data** `object`

**data**

**concepts** `array`

Array of matching concepts

**concept object**

**concept\_id** `integer`

Unique concept identifier

**concept\_name** `string`

Human-readable concept name

**concept\_code** `string`

Concept code within its vocabulary

**vocabulary\_id** `string`

Source vocabulary identifier

**vocabulary\_name** `string`

Human-readable vocabulary name

**domain\_id** `string`

Concept domain classification

**concept\_class\_id** `string`

Concept class within vocabulary

**standard\_concept** `string`

Standard concept designation (S = Standard, C = Classification)

**valid\_start\_date** `string`

Date when concept became valid

**valid\_end\_date** `string`

Date when concept becomes invalid

**invalid\_reason** `string`

Reason for invalidity (if applicable)

**search\_score** `number`

Normalized effective relevance score in the range `[0, 1)`. For
relevance sorting, higher values always rank ahead of lower values.

**facets** `object`

Available facets for further filtering

**facets**

**vocabularies** `array`

Vocabulary facets with counts

**domains** `array`

Domain facets with counts

**concept\_classes** `array`

Concept class facets with counts

**years** `array`

Valid-start year facets with counts

**facet\_status** `object`

Facet completion status. `partial` is `true` when any category failed, and `failed_facets` identifies the affected categories.
Responses use the API-wide `Cache-Control: no-store` client policy whether facets are complete or partial. Eligible complete responses may still use OMOPHub's internal Redis cache.

**facet\_status**

**partial** `boolean`

Whether one or more facet categories failed

**failed\_facets** `array`

Failed category names: `vocabularies`, `domains`, `concept_classes`, or `years`

**search\_metadata** `object`

Search execution metadata

**search\_metadata**

**query\_time\_ms** `integer`

Query execution time in milliseconds

**total\_results** `integer`

Total number of matching concepts

**max\_relevance\_score** `number`

Highest relevance score in results

**search\_algorithm** `string`

Search algorithm used

**meta** `object`

Response metadata including pagination

**meta**

**request\_id** `string`

Unique identifier for this request

**timestamp** `string`

ISO 8601 timestamp of the response

**vocab\_release** `string`

Vocabulary release version used

**search** `object`

Search metadata

**search**

**query** `string`

The search query used

**total\_results** `integer`

Total number of matching concepts

**filters\_applied** `object`

Filters that were applied to the search

**pagination** `object`

Pagination information

**pagination**

**page** `integer`

Current page number

**page\_size** `integer`

Number of results per page

**total\_items** `integer`

Total number of results

**total\_pages** `integer`

Total number of pages

**has\_next** `boolean`

Whether a next page exists

**has\_previous** `boolean`

Whether a previous page exists

## Examples

### Basic Search

```bash cURL theme={null}
curl -X POST "https://api.omophub.com/v1/search/advanced" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "diabetes mellitus type 2",
    "page_size": 10
  }'
```

```python Python theme={null}
results = client.search.advanced_search(
    query="diabetes mellitus type 2",
    page_size=10
)

for concept in results.data:
    print(f"{concept.concept_id}: {concept.concept_name}")
    print(f"  Vocabulary: {concept.vocabulary_id}")
    print(f"  Score: {concept.search_score:.3f}")
```

```ts TypeScript theme={null}
import { OMOPHub } from '@omophub/omophub-node';

const client = new OMOPHub();
const { data: results } = await client.search.advanced({
  query: 'diabetes mellitus type 2',
  pageSize: 10,
});

results?.forEach(concept => {
  console.log(`${concept.concept_id}: ${concept.concept_name}`);
  console.log(`  Vocabulary: ${concept.vocabulary_id}`);
  console.log(`  Score: ${concept.search_score?.toFixed(3)}`);
});
```

```r R theme={null}
results <- advanced_search_concepts(client,
  query = "diabetes mellitus type 2",
  page_size = 10
)

for (i in 1:nrow(results$data$concepts)) {
  concept <- results$data$concepts[i, ]
  cat(paste(concept$concept_id, concept$concept_name, sep = ": "), "\n")
  cat(paste("  Vocabulary:", concept$vocabulary_id), "\n")
  cat(paste("  Score:", round(concept$search_score, 3)), "\n")
}
```

```json Example Response theme={null}
{
  "success": true,
  "data": {
    "concepts": [
      {
        "concept_id": 201826,
        "concept_name": "Type 2 diabetes mellitus",
        "concept_code": "44054006",
        "vocabulary_id": "SNOMED",
        "vocabulary_name": "Systematized Nomenclature of Medicine Clinical Terms",
        "domain_id": "Condition",
        "concept_class_id": "Clinical Finding",
        "standard_concept": "S",
        "valid_start_date": "1970-01-01",
        "valid_end_date": "2099-12-31",
        "invalid_reason": null,
        "search_score": 0.843
      },
      {
        "concept_id": 435216,
        "concept_name": "Diabetes mellitus type 2 in obese",
        "concept_code": "E11.0",
        "vocabulary_id": "ICD10CM",
        "vocabulary_name": "International Classification of Diseases, Tenth Revision, Clinical Modification",
        "domain_id": "Condition",
        "concept_class_id": "4-char billing code",
        "standard_concept": null,
        "valid_start_date": "2015-10-01",
        "valid_end_date": "2099-12-31",
        "invalid_reason": null,
        "search_score": 0.786
      }
    ],
    "facets": {
      "vocabularies": [
        {"vocabulary_id": "SNOMED", "vocabulary_name": "SNOMED CT", "count": 45},
        {"vocabulary_id": "ICD10CM", "vocabulary_name": "ICD-10-CM", "count": 23},
        {"vocabulary_id": "ICD9CM", "vocabulary_name": "ICD-9-CM", "count": 12}
      ],
      "domains": [
        {"domain_id": "Condition", "domain_name": "Condition", "count": 67},
        {"domain_id": "Observation", "domain_name": "Observation", "count": 13}
      ],
      "concept_classes": [
        {"concept_class_id": "Clinical Finding", "concept_class_name": "Clinical Finding", "count": 45},
        {"concept_class_id": "4-char billing code", "concept_class_name": "4-char billing code", "count": 23}
      ],
      "years": [
        {"year": 1970, "count": 45},
        {"year": 2015, "count": 23}
      ]
    },
    "facet_status": {
      "partial": false,
      "failed_facets": []
    },
    "search_metadata": {
      "query_time_ms": 127,
      "total_results": 80,
      "max_relevance_score": 10,
      "search_algorithm": "full_text_with_ranking"
    }
  },
  "meta": {
    "request_id": "req_adv_search_abc123",
    "timestamp": "2024-01-15T10:30:00Z",
    "vocab_release": "2025.1",
    "search": {
      "query": "diabetes mellitus type 2",
      "total_results": 80,
      "filters_applied": {
        "vocabulary_ids": [],
        "domain_ids": [],
        "standard_concepts_only": false,
        "include_invalid": true
      }
    },
    "pagination": {
      "page": 1,
      "page_size": 10,
      "total_items": 80,
      "total_pages": 8,
      "has_next": true,
      "has_previous": false
    }
  }
}
```

### Filtered Search

```bash cURL theme={null}
curl -X POST "https://api.omophub.com/v1/search/advanced" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "hypertension",
    "vocabulary_ids": ["SNOMED", "ICD10CM"],
    "domain_ids": ["Condition"],
    "standard_concepts_only": true,
    "date_range": {
      "start_date": "2020-01-01",
      "end_date": "2024-12-31"
    },
    "page_size": 20
  }'
```

```python Python theme={null}
results = client.search.advanced_search(
    query="hypertension",
    vocabulary_ids=["SNOMED", "ICD10CM"],
    domain_ids=["Condition"],
    standard_concepts_only=True,
    date_range={
        "start_date": "2020-01-01",
        "end_date": "2024-12-31"
    },
    page_size=20
)

print(f"Found {results.meta.pagination.total_items} concepts")
print(f"Query executed in {results.data.search_metadata.query_time_ms}ms")
```

```ts TypeScript theme={null}
import { OMOPHub } from '@omophub/omophub-node';

const client = new OMOPHub();
const { data: results, meta } = await client.search.advanced({
  query: 'hypertension',
  vocabularyIds: ['SNOMED', 'ICD10CM'],
  domainIds: ['Condition'],
  standardConceptsOnly: true,
  dateRange: {
    startDate: '2020-01-01',
    endDate: '2024-12-31',
  },
  pageSize: 20,
});

console.log(`Found ${meta?.pagination?.total_items} concepts`);
```

```r R theme={null}
results <- advanced_search_concepts(client,
  query = "hypertension",
  vocabulary_ids = c("SNOMED", "ICD10CM"),
  domain_ids = c("Condition"),
  standard_concepts_only = TRUE,
  date_range = list(
    start_date = "2020-01-01",
    end_date = "2024-12-31"
  ),
  page_size = 20
)

cat(paste("Found", results$meta$pagination$total_items, "concepts\n"))
cat(paste("Query executed in", results$data$search_metadata$query_time_ms, "ms\n"))
```

### Complex Relationship Filtering

```bash cURL theme={null}
curl -X POST "https://api.omophub.com/v1/search/advanced" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "insulin",
    "vocabulary_ids": ["RxNorm"],
    "domain_ids": ["Drug"],
    "relationship_filters": [
      {
        "relationship_id": "RxNorm has dose form",
        "target_concept_id": 19127776,
        "direction": "forward"
      }
    ],
    "concept_class_ids": ["Clinical Drug"],
    "page_size": 15
  }'
```

```python Python theme={null}
results = client.search.advanced_search(
    query="insulin",
    vocabulary_ids=["RxNorm"],
    domain_ids=["Drug"],
    relationship_filters=[
        {
            "relationship_id": "RxNorm has dose form",
            "target_concept_id": 19127776,
            "direction": "forward"
        }
    ],
    concept_class_ids=["Clinical Drug"],
    page_size=15
)

for concept in results.data:
    print(f"Drug: {concept.concept_name}")
    print(f"  Code: {concept.concept_code}")
    print(f"  Class: {concept.concept_class_id}")
```

```ts TypeScript theme={null}
import { OMOPHub } from '@omophub/omophub-node';

const client = new OMOPHub();
const { data: results } = await client.search.advanced({
  query: 'insulin',
  vocabularyIds: ['RxNorm'],
  domainIds: ['Drug'],
  relationshipFilters: [
    {
      relationship_id: 'RxNorm has dose form',
      target_concept_id: 19127776,
      direction: 'forward',
    },
  ],
  conceptClassIds: ['Clinical Drug'],
  pageSize: 15,
});

results.data.forEach(concept => {
  console.log(`Drug: ${concept.concept_name}`);
  console.log(`  Code: ${concept.concept_code}`);
  console.log(`  Class: ${concept.concept_class_id}`);
});
```

```r R theme={null}
results <- advanced_search_concepts(client,
  query = "insulin",
  vocabulary_ids = c("RxNorm"),
  domain_ids = c("Drug"),
  relationship_filters = list(
    list(
      relationship_id = "RxNorm has dose form",
      target_concept_id = 19127776,
      direction = "forward"
    )
  ),
  concept_class_ids = c("Clinical Drug"),
  page_size = 15
)

for (i in 1:nrow(results$data$concepts)) {
  concept <- results$data$concepts[i, ]
  cat(paste("Drug:", concept$concept_name), "\n")
  cat(paste("  Code:", concept$concept_code), "\n")
  cat(paste("  Class:", concept$concept_class_id), "\n")
}
```

## Search Features

### Full-Text Search

* **Multi-field search**: Searches concept names, synonyms, and descriptions
* **Phrase matching**: Use quotes for exact phrases: `"myocardial infarction"`
* **Wildcard support**: Use `*` for partial matching: `diabet*`
* **Boolean operators**: Use AND, OR, NOT: `diabetes AND type 2`

### Relevance Scoring

`search_score` is the normalized form of the shared deterministic ranking
policy. Exact concept IDs and codes occupy the highest band. Text searches then
use non-overlapping clinical-utility bands (valid Standard, Classification,
valid non-standard, non-clinical artifact, invalid), with exact primary name,
exact published synonym, prefix/phrase, token/full-text, and fuzzy/substring
evidence ordered inside each band. Correlated text signals cannot cross a
utility or evidence boundary.

`min_score` is deliberately different: it filters the bounded lexical-evidence
component only. For example, `0.6` retains exact primary-name and exact synonym
evidence without treating a lower clinical-utility tier as insufficient merely
because it is lower utility.

### Result Ordering

With the default `sort_by=relevance`, `search_score` is authoritative, followed
by deterministic core-clinical-domain, vocabulary-authority, name-length, name,
and `concept_id` tie-breaks. The same score and order are used by optimized and
fallback paths.

`sort_by=name`, `code` and `date` are honoured exactly as asked and are not
reordered by the policy.

Passing a demoted class in `concept_class_ids` turns its demotion off, the same
way it does on
[`/v1/search/concepts`](https://docs.omophub.com/api-reference/search/basic-search#default-ranking-policy).

### Faceted Search

Use facets to understand result distribution:

```python theme={null}
# Access facets for filtering insights
facets = results.data.facets

print("Available vocabularies:")
for vocab in facets.vocabularies:
    print(f"  {vocab.vocabulary_name}: {vocab.count} concepts")

print("\nAvailable domains:")
for domain in facets.domains:
    print(f"  {domain.domain_name}: {domain.count} concepts")
```

## Performance Tips

1. **Use specific vocabulary\_ids**: Limit search to relevant vocabularies only
2. **Filter by domain\_ids**: Reduce result set with domain filters
3. **Reasonable page sizes**: Use page\_size of 20-100 for best performance
4. **Cache results**: Cache frequently accessed searches
5. **Use standard concepts**: Set `standard_concepts_only: true` for faster queries
6. **Avoid broad queries**: Queries shorter than 3 characters, including an omitted query, require at least one `vocabulary_ids`, `domain_ids`, or `concept_class_ids` filter.

## Related Endpoints

> [card] [Basic Search](https://docs.omophub.com/api-reference/search/basic-search.md)
>
> Simple concept search with minimal parameters

> [card] [Search Autocomplete](https://docs.omophub.com/api-reference/search/search-autocomplete.md)
>
> Real-time search suggestions

> [card] [Similar Concepts](https://docs.omophub.com/api-reference/search/search-similar.md)
>
> Find semantically similar concepts

> [card] [Search Facets](https://docs.omophub.com/api-reference/search/search-facets.md)
>
> Get available search facets


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.