Skip to main content

Atom Search

Search atoms using pattern matching and semantic search capabilities.

Query Structure​

query SearchAtoms($search: String!, $limit: Int!) {
atoms(
where: {
_or: [
{ label: { _ilike: $search } }
{ data: { _ilike: $search } }
]
}
limit: $limit
) {
term_id
label
image
type
}
}
query SemanticSearch($query: String!, $limit: Int) {
search_term(args: { query: $query }, limit: $limit) {
atom {
term_id
label
type
image
}
}
}

Interactive Examples​

Query

query SearchAtoms($search: String!, $limit: Int!) {
  atoms(
    where: {
      _or: [
        { label: { _ilike: $search } }
        { data: { _ilike: $search } }
      ]
    }
    order_by: { created_at: desc }
    limit: $limit
  ) {
    term_id
    label
    image
    type
  }
}

Variables

Click "Run Query" to execute the GraphQL query and see results

Search Patterns​

query SearchCaseInsensitive($term: String!) {
atoms(
where: { label: { _ilike: $term } }
limit: 20
) {
term_id
label
}
}
query MultiFieldSearch($search: String!) {
atoms(
where: {
_or: [
{ label: { _ilike: $search } }
{ data: { _ilike: $search } }
]
}
) {
term_id
label
}
}

Filter Search by Type​

query SearchPersons($search: String!, $type: atom_type!) {
atoms(
where: {
type: { _eq: $type }
label: { _ilike: $search }
}
) {
term_id
label
}
}

Use Cases​

Autocomplete​

const query = `
query Autocomplete($search: String!) {
atoms(
where: { label: { _ilike: $search } }
order_by: { label: asc }
limit: 10
) {
term_id
label
image
}
}
`

// User types "eth" β†’ search for "%eth%"
const query = `
query GlobalSearch($search: String!) {
atoms(
where: { label: { _ilike: $search } }
limit: 20
) {
term_id
label
type
}
}
`

Performance Considerations​

  • Use wildcards sparingly: %term% is slower than term%
  • Limit results: Always include limit
  • Consider semantic search: For natural language queries

Best Practices​

  1. Use _ilike for case-insensitive searches
  2. Add wildcards strategically: %term or term% or %term%
  3. Combine with type filters to narrow results
  4. Limit results to prevent over-fetching