Skip to content

pymat.search(query) — fuzzy search over the domain library (incl. grades) #85

@gerchowl

Description

@gerchowl

Summary

pymat.search(query: str, *, limit: int = 10) -> list[Material] as a top-level fuzzy-find over the loaded library. Complements pymat.vis.search(...) (visual catalog) with a symmetric domain-side verb.

Design

Tokenized + weighted-target matching over a flat registry — grades, variants, vendors are already first-class:

  • registry key: weight 10
  • Material.name / grade: weight 5
  • hierarchy parent names: weight 3

All tokens must match somewhere (conjunctive). Ties broken by shorter key.

Triggers load_all() so results are exhaustive. Case-insensitive.

Examples

pymat.search("stainless")         # → [stainless, s304, s316L, ...]
pymat.search("316")               # → [s316L, s316, ...]
pymat.search("stainless 316")     # → [s316L]   # all tokens must match
pymat.search("lyso ce saint")     # → [prelude420, ...]   # deep hierarchy

Out of scope for v1

  • Scoped search (kind="grade" / kind="parent") — optional follow-up.
  • Aliases / synonyms — punt.
  • Levenshtein via rapidfuzz — substring + token is enough. Optional extra later if needed.
  • Property filters ("density > 8") — different API.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions