Back to Changelog
Featurev1.4.0

SDK v1.4.0: Semantic Search for Python & R

Python and R SDKs now support semantic search and concept similarity with natural language queries.

We're excited to announce SDK v1.4.0 for both Python and R, bringing native support for the semantic search and similarity capabilities we launched last week. You can now find medical concepts using natural language directly from your SDK of choice.

Use everyday language to find OMOP concepts — no need to know exact terminology:

# Python
results = client.search.semantic("heart attack", domain_ids="Condition", page_size=5)
for concept in results:
    print(f"{concept.concept_name} ({concept.vocabulary_id}) — score: {concept.score:.2f}")
# Myocardial infarction (SNOMED) — score: 0.94
# R
results <- client$search$semantic("heart attack", domain_ids = "Condition", page_size = 5)
results
#>   concept_name                vocabulary_id  score
#> 1 Myocardial infarction       SNOMED         0.94

Filter by vocabulary, domain, standard concept status, and more — the same parameters available in the REST API.

Auto-Pagination

Iterate through all results without manual page management:

# Python — lazy iterator, fetches pages on demand
for concept in client.search.semantic_iter("high blood pressure", vocabulary_ids="SNOMED"):
    print(concept.concept_name)
# R — fetches all pages and returns a single data frame
all_results <- client$search$semantic_all("high blood pressure", vocabulary_ids = "SNOMED")
nrow(all_results)

Find concepts similar to a query using different matching algorithms:

# Python
results = client.search.similar(
    "sugar diabetes",
    vocabulary_ids=["SNOMED", "ICD10CM"],
    algorithm="semantic",
    similarity_threshold=0.7,
    include_explanations=True,
)
for concept in results:
    print(f"{concept.concept_name}{concept.explanation}")
# R
results <- client$search$similar(
  "sugar diabetes",
  vocabulary_ids = c("SNOMED", "ICD10CM"),
  algorithm = "semantic",
  similarity_threshold = 0.7,
  include_explanations = TRUE
)
results[, c("concept_name", "explanation")]

Available Algorithms

AlgorithmBest ForExample
semanticConceptual similarity"heart attack" → "Myocardial infarction"
lexicalFuzzy text matching, typo tolerance"diabetis" → "diabetes"
hybrid (default)Balanced matchingCombines word + character similarity

Install or Upgrade

# Python
pip install --upgrade omophub
# R
install.packages("omophub")

Resources