---
title: PubChem structure and similarity search
description: >-
  Run exact, substructure, and similarity searches against PubChem using
  SMILES, InChIKey, or a CID.
---

Structure-based search lets you query [PubChem](/docs/pubchem) by SMILES, InChIKey, or CID for exact matches, substructure motifs, or Tanimoto-ranked similar compounds. For similarity search the threshold most affects the result: start near 90 for close analogs and lower toward 60-70 to broaden the search.

## PubChem structure and similarity search

Use structure-based queries when you have SMILES, InChIKey, or a CID. You run them by asking Ivy in chat, for example *"Find PubChem compounds at least 80% similar to gefitinib"*.

## Exact search

- Provide canonical SMILES or InChIKey for the most precise match.
- Use exact when you need a single canonical record (CID).

## Substructure search

- Give Ivy a substructure SMILES or SMARTS pattern; the search runs PubChem's fingerprint-based substructure screening (`fastsubstructure`).
- Useful for scaffold exploration; expect broader result sets than exact.
- Returns 20 compounds by default; ask for up to 50.

## Similarity search

- Give Ivy a compound name, SMILES, or CID plus a similarity threshold.
- The threshold is an **integer 0-100** (not a 0.0-1.0 Tanimoto fraction) — minimum 50, default 90.
- Start at 90 for close analogs; lower toward 60-70 for broader exploration.
- Higher thresholds yield fewer, more similar hits. Returns 20 compounds by default; ask for up to 100.

## Tips

- Normalize salts/charges before submission to avoid duplicated hits.
- Capture the threshold and search mode in logs so exports stay reproducible.
- If results seem empty, retry with similarity search at a lower threshold.
