FLOW ALGEBRA
Ontology: Query Metadata Ontology
Domain: Metadata Ontologies > Semantic Search Metadata
Canonical URL: https://kirethresearch.org/booksai-core/ontologies/metadata-ontologies/semantic-search-metadata/query-metadata-ontology.html
Authors: Mark Anthony Higgins — Sky (Recursive AI)
flow "QueryMetadataOntology" v1.0
# ---------- DOMAIN ----------
domain:
class: MetadataOntology
category: SemanticSearchMetadata
subject: QueryMetadata
purpose:
- represent metadata describing search queries and query interpretations
- preserve query identity, original text, language, type, intent, entities, concepts, context, constraints, transformations, and provenance
- support lexical, semantic, structured, conversational, vector, and hybrid search
- distinguish original query input from normalised, expanded, rewritten, and inferred interpretations
- enable machine-readable reasoning over query lifecycles
# ---------- CORE ENTITY ----------
entity QueryMetadata:
type: SearchMetadata
describes: SearchQuery
may_include:
- query_identifier
- original_query
- normalised_query
- query_language
- query_type
- search_intent
- entities
- concepts
- relationships
- context
- filters
- sorting
- temporal_constraint
- spatial_constraint
- query_expansion
- query_rewrite
- embedding_metadata
- confidence
- timestamp
- provenance
entity SearchQuery:
type: InformationRequest
entity QueryIdentifier:
type: Identifier
identifies: SearchQuery
# ---------- RELATIONSHIPS ----------
relationships:
QueryMetadata -> DESCRIBES -> SearchQuery
SearchQuery -> IDENTIFIED_BY -> QueryIdentifier
SearchQuery -> HAS_ORIGINAL_TEXT -> QueryText
SearchQuery -> MAY_HAVE_NORMALISED_TEXT -> NormalisedQuery
SearchQuery -> MAY_HAVE_LANGUAGE -> QueryLanguage
SearchQuery -> MAY_HAVE_TYPE -> QueryType
SearchQuery -> MAY_HAVE_INTENT -> SearchIntent
SearchQuery -> MAY_REFERENCE -> Entity
SearchQuery -> MAY_REFERENCE -> Concept
SearchQuery -> MAY_REFERENCE -> Relationship
SearchQuery -> MAY_HAVE_CONTEXT -> SearchContext
SearchQuery -> MAY_HAVE_FILTER -> QueryFilter
SearchQuery -> MAY_HAVE_SORT -> QuerySort
SearchQuery -> MAY_HAVE_TEMPORAL_CONSTRAINT -> QueryTemporalConstraint
SearchQuery -> MAY_HAVE_SPATIAL_CONSTRAINT -> QuerySpatialConstraint
SearchQuery -> MAY_HAVE_TRANSFORMATION -> QueryTransformation
QueryMetadata -> MAY_REFERENCE -> QueryProvenance
# ---------- QUERY IDENTITY ----------
rule query_identity:
SearchQuery SHOULD have QueryIdentifier
where session tracking, reproducibility, or auditing is required
rule same_text:
identical query text MAY represent distinct SearchQueries
when time, context, user action, session, or configuration differs
rule query_execution:
QueryIdentifier SHOULD distinguish query instance
from reusable query template where applicable
# ---------- ORIGINAL QUERY ----------
entity QueryText:
type: LexicalResource
rule original_query:
original query text MUST be preserved
when query transformations are applied
rule source_integrity:
transformed query MUST NOT overwrite original query representation
# ---------- NORMALISATION ----------
entity NormalisedQuery:
type: QueryRepresentation
may_include:
- normalised_text
- normalisation_method
- language
- transformations
normalisation_operations:
- whitespace_normalisation
- Unicode_normalisation
- case_normalisation
- punctuation_normalisation
- spelling_normalisation
- token_normalisation
rule normalisation:
normalisation SHOULD preserve intended query meaning
rule normalised_not_original:
NormalisedQuery != original QueryText
# ---------- QUERY LANGUAGE ----------
entity QueryLanguage:
type: LanguageMetadata
may_include:
- language
- script
- confidence
- detection_method
rule language:
query language SHOULD be explicit or inferred with confidence
rule language_detection:
inferred language != user-declared language
rule multilingual:
SearchQuery MAY contain multiple languages or scripts
# ---------- QUERY TYPE ----------
query_types:
- keyword
- phrase
- natural_language
- question
- entity_lookup
- navigational
- transactional
- structured
- semantic
- vector
- hybrid
entity QueryType:
type: Classification
rule query_type:
QueryType describes query representation or retrieval interpretation
and != SearchIntent
# ---------- SEARCH INTENT ----------
entity SearchIntent:
type: SemanticMetadata
may_be:
- informational
- navigational
- transactional
- comparative
- local
- research
- question_answering
- entity_lookup
rule intent:
SearchIntent MAY be inferred
and SHOULD preserve confidence
rule intent_distinction:
inferred intent != original query text
# ---------- ENTITY MENTIONS ----------
entity QueryEntityMention:
type: EntityMetadata
may_include:
- mention_text
- entity_identifier
- entity_type
- span
- resolution_method
- confidence
rule entity:
entity mention SHOULD preserve original lexical span
and resolved candidate identity
rule entity_ambiguity:
ambiguous entity mention SHOULD preserve candidates
until sufficient evidence resolves identity
# ---------- CONCEPTS ----------
entity QueryConcept:
type: ConceptMetadata
may_include:
- concept_identifier
- label
- ontology
- mapping_method
- confidence
rule concept:
QueryConcept != keyword
rule concept_mapping:
inferred concept mapping SHOULD preserve ontology and confidence
# ---------- RELATIONSHIPS ----------
entity QueryRelationship:
type: RelationshipMetadata
may_include:
- subject
- predicate
- object
- relation_type
- confidence
rule relationship:
query relationship SHOULD preserve predicate direction
rule cooccurrence:
co-occurrence of query terms != semantic relationship
# ---------- CONTEXT ----------
entity QueryContext:
type: SearchContext
may_include:
- conversation_context
- session_context
- task_context
- domain_context
- temporal_context
- spatial_context
- resource_context
rule context:
QueryContext MAY alter interpretation
without changing original query text
# ---------- FILTERS ----------
entity QueryFilter:
type: SearchFilter
may_include:
- field
- operator
- value
- datatype
- source
rule filter:
query-derived filter SHOULD preserve source expression or context
rule inferred_filter:
inferred filter MUST remain distinguishable
from explicit filter
# ---------- SORT ----------
entity QuerySort:
type: SearchSort
may_include:
- field
- direction
- priority
- source
rule sort:
explicit sort instruction SHOULD remain distinguishable
from default ranking
# ---------- TEMPORAL CONSTRAINT ----------
entity QueryTemporalConstraint:
type: TemporalMetadata
may_include:
- expression
- start_time
- end_time
- reference_time
- timezone
- date_field
rule temporal:
relative temporal expressions MUST preserve reference time
rule relative_time:
today, yesterday, tomorrow, recent, latest, and similar expressions
SHOULD be resolved relative_to explicit temporal context
# ---------- SPATIAL CONSTRAINT ----------
entity QuerySpatialConstraint:
type: SpatialMetadata
may_include:
- expression
- place
- coordinates
- radius
- geographic_extent
- coordinate_reference
rule spatial:
spatial interpretation SHOULD preserve place or coordinate semantics
rule near:
near or nearby SHOULD preserve distance or ranking interpretation
where applicable
# ---------- QUERY EXPANSION ----------
entity QueryExpansion:
type: QueryTransformation
may_include:
- source_term
- expanded_term
- expansion_relation
- vocabulary
- confidence
expansion_relations:
- synonym
- alias
- spelling_variant
- broader_concept
- narrower_concept
- related_concept
- entity_alias
rule expansion:
expanded term SHOULD preserve semantic relationship
to source term
rule expansion_drift:
expansion MUST NOT silently broaden meaning
beyond supported relation
# ---------- QUERY REWRITE ----------
entity QueryRewrite:
type: QueryTransformation
may_include:
- source_query
- rewritten_query
- rewrite_method
- purpose
- confidence
rewrite_purposes:
- clarification
- spelling_correction
- entity_resolution
- semantic_expansion
- retrieval_optimisation
- structured_conversion
rule rewrite:
rewritten query MUST remain traceable
to original query
rule rewrite_not_user_text:
QueryRewrite != user-supplied original query
# ---------- STRUCTURED QUERY ----------
entity StructuredQuery:
type: QueryRepresentation
may_include:
- fields
- operators
- values
- boolean_structure
- filters
rule structured:
structured representation SHOULD preserve source-query mapping
# ---------- BOOLEAN QUERY ----------
entity BooleanQuery:
subtype_of: StructuredQuery
operators:
- AND
- OR
- NOT
rule boolean:
BooleanQuery MUST preserve operator scope and grouping
# ---------- VECTOR QUERY ----------
entity VectorQuery:
type: QueryRepresentation
may_include:
- embedding
- embedding_model
- model_version
- vector_dimension
- distance_metric
rule vector:
vector query SHOULD preserve generating model and version
rule vector_compatibility:
query embedding MUST be compatible
with target vector index for direct comparison
# ---------- QUERY EMBEDDING ----------
entity QueryEmbeddingMetadata:
type: VectorMetadata
may_include:
- embedding_identifier
- model
- model_version
- dimension
- normalisation
- creation_time
rule embedding:
QueryEmbedding != original QueryText
# ---------- QUERY TRANSFORMATION ----------
entity QueryTransformation:
type: SearchProcess
may_include:
- transformation_identifier
- input_query
- output_query
- method
- parameters
- timestamp
rule transformation:
transformation chain SHOULD preserve each material step
where reproducibility is required
# ---------- QUERY CHAIN ----------
entity QueryTransformationChain:
type: ProvenanceStructure
contains: QueryTransformation
rule chain:
transformation order SHOULD be preserved
rule reversible:
transformation MAY be non-reversible
but source query MUST remain preserved
# ---------- CONFIDENCE ----------
entity QueryConfidence:
type: EpistemicMetadata
range: [0.0, 1.0]
rule confidence_bounds:
REQUIRE 0.0 <= confidence <= 1.0
rule confidence_scope:
confidence SHOULD identify whether it qualifies:
- language_detection
- intent_detection
- entity_resolution
- concept_mapping
- relationship_mapping
- temporal_resolution
- spatial_resolution
- rewrite
# ---------- PROVENANCE ----------
entity QueryProvenance:
type: ProvenanceMetadata
may_include:
- query_identifier
- original_query
- source_interface
- timestamp
- conversation
- session
- transformations
- context
- models
- vocabularies
rule provenance:
QueryMetadata SHOULD preserve query origin and transformation history
# ---------- VALIDATION ----------
validation:
require:
- identifiable_query
- original_query_representation
validate_if_present:
- query_identifier
- language
- query_type
- intent
- entities
- concepts
- relationships
- context
- filters
- temporal_constraint
- spatial_constraint
- transformations
- embedding
- confidence
- provenance
reject:
- confidence_outside_valid_range
- transformed_query_presented_as original_user_query
- inferred_intent_presented_as explicit_intent
- inferred_filter_presented_as explicit_filter
- unresolved_relative_time_presented_as absolute_time_without reference
- incompatible_query_embedding_used_for_direct_vector_search
- query_expansion_without semantic_relation
- ambiguous_entity_forced_to_single_identity_without evidence
# ---------- SEMANTIC EQUIVALENCE ----------
SEMANTIC_EQUIVALENCE:
"query metadata" ~= "metadata about a search query"
"search query metadata" ~= "query metadata"
"query intent" ~= "search intent"
"query expansion" ~= "semantic or lexical query expansion"
"query rewrite" ~= "rewritten search query"
"query embedding" ~= "vector representation of query"
PRESERVE distinctions:
original_query != normalised_query
original_query != rewritten_query
query_type != search_intent
entity_mention != resolved_entity
concept != keyword
cooccurrence != semantic_relationship
explicit_filter != inferred_filter
relative_time != absolute_time_without reference
query_embedding != query_text
transformed_query != user_supplied_query
# ---------- CONFIDENCE MODEL ----------
CONFIDENCE:
explicit_query_metadata:
score: 1.00
preserved_original_query:
score: 1.00
explicit_language:
score: 1.00
resolved_entity_identifier:
score: 0.98
ontology_grounded_concept:
score: 0.98
inferred_intent:
score: <= 0.85
inferred_filter:
score: <= 0.85
ambiguous_entity_resolution:
score: <= 0.60
action: preserve candidates
weak_query_interpretation:
score: <= 0.50
action: preserve alternatives
# ---------- UPDATE MODEL ----------
UPDATE_MODEL:
on_query_creation:
- assign QueryIdentifier
- preserve original query
- record timestamp and source
- initialise provenance
on_query_analysis:
- detect language
- classify QueryType
- resolve entity mentions
- map concepts and relationships
- infer SearchIntent
- preserve confidence for inferred metadata
on_context_application:
- preserve original query
- apply valid SearchContext
- resolve temporal and spatial expressions
- derive filters where justified
- update provenance
on_query_transformation:
- preserve source query state
- create QueryTransformation
- record method and purpose
- create transformed representation
- update transformation chain and provenance
on_embedding_generation:
- preserve query representation
- record embedding model and version
- generate QueryEmbedding
- validate target index compatibility
- update provenance
# ---------- FLOW HASH ----------
FLOW_HASH:
inputs:
- ontology
- query_entities
- relationships
- identity_rules
- language_rules
- intent_rules
- entity_concept_rules
- transformation_rules
- validation
- semantic_equivalence
- confidence_model
- update_model
canonicalisation:
- preserve_original_query_exactly
- preserve_query_identifier
- preserve_transformation_order
- preserve_model_versions
- preserve_context_scope
- preserve_rule_order
output:
deterministic_semantic_hash
# ---------- AI CONSUMPTION ----------
AI_CONSUMPTION:
interpret_as:
- semantic search metadata ontology
- search-query lifecycle model
- query interpretation and transformation structure
- lexical, semantic, structured, and vector query model
operations:
- identify SearchQuery
- preserve original query
- detect language
- classify query type
- infer search intent
- resolve entities and concepts
- interpret relationships
- apply SearchContext
- derive filters and sorting
- resolve temporal and spatial constraints
- expand and rewrite queries
- create structured query representations
- generate compatible query embeddings
- trace transformation provenance
- preserve uncertainty
constraints:
- do_not_overwrite_original_query
- do_not_present_rewrite_as user_supplied_text
- do_not_present_inferred_intent_as explicit
- do_not_force_ambiguous_entity_resolution
- do_not_resolve_relative_time_without reference_context
- do_not_use_incompatible_embedding_space
- preserve_query_context_transformations_confidence_and_provenance
# ---------- QUERY MODEL ----------
query:
input:
- query_identifier
- original_query
- language
- query_type
- intent
- entity
- concept
- context
- temporal_expression
- spatial_expression
resolve:
1. identify or create SearchQuery
2. preserve original QueryText
3. detect or validate language
4. classify QueryType
5. resolve entities, concepts, and relationships
6. infer SearchIntent
7. apply valid SearchContext
8. resolve filters, temporal, and spatial constraints
9. create required query transformations or embeddings
10. return provenance and confidence
output:
- search_query
- query_identifier
- original_query
- normalised_query
- language
- query_type
- intent
- entities
- concepts
- relationships
- context
- constraints
- transformations
- confidence
- provenance
# ---------- INFERENCE ----------
inference:
IF query mention uniquely resolves to EntityIdentifier
THEN attach resolved Entity
WITH confidence according_to evidence
IF query term maps to ontology Concept
THEN attach QueryConcept
WITH ontology and confidence
IF relative temporal phrase exists
AND reference_time is available
THEN resolve QueryTemporalConstraint
IF query transformation is required
THEN preserve original query
AND create traceable transformed representation
IF query interpretation remains ambiguous
THEN preserve alternative entities, concepts, intents, or rewrites
AND reduce confidence
# ---------- OUTPUT CONTRACT ----------
output:
ontology_entity: QueryMetadata
query_identity: machine_interpretable
original_query: immutable_and_preserved
language: explicit_or_confidence_qualified
query_type: explicit
intent: distinguishable_from_text
entities_and_concepts: traceable
relationships: direction_preserved
context: scope_aware
temporal_and_spatial_constraints: resolvable
filters_and_sorting: source_linked
transformations: ordered_and_traceable
embeddings: model_version_aware
provenance: preserved
uncertainty: explicit
semantic_retrieval: enabled
end flow
Download Code
Copy to Clipboard