Taxonomies
Taxonomies are hierarchical classification systems that define relationships between different data values. They enable powerful filtering and searching by linking entities at different levels of a hierarchy, allowing you to query at any level and automatically retrieve all related records.
Structure
A taxonomy consists of entries with four key components:
- Child Type: The category or field name at the lower level
- Parent Type: The category or field name at the higher level
- Child Value: The specific value or instance at the lower level
- Parent Value: The specific value or instance at the higher level
This creates a mapping: child_type → child_value belongs to parent_type → parent_value
Example: Geographic Hierarchy
Consider a geographic taxonomy with the following entries:
city, state, San Francisco, California
state, country, California, USA
state, country, New York, USA
This establishes the relationships:
- San Francisco is a city in California
- California is a state in USA
- New York is a state in USA
Querying with Taxonomies
Once taxonomies are defined, you can search at any level and automatically retrieve all related records:
Direct Query
city = San Francisco
→ Returns: San Francisco
Hierarchical Query
state = California
→ Returns: All cities in California (San Francisco, and others)
Top-Level Query
country = USA
→ Returns: All cities in all states in USA (San Francisco, New York, and all others)
Use Cases
Taxonomies are ideal for scenarios where you have multi-level hierarchies:
- Geographic data: Countries → States → Cities
- Organization structure: Company → Department → Team → Employee
- Product categories: Category → Subcategory → Product → SKU
- Document classification: Topic → Subtopic → Specific Document Type
By defining these relationships once in your taxonomy, you enable flexible querying that respects the full hierarchy, making it easy to retrieve records at any classification level without writing complex queries.