Query Models
grizabella.core.query_models
Pydantic models for Grizabella Complex Query Engine.
ComplexQuery
Bases: BaseModel
Represents a complex query that can span multiple database layers and object types.
Source code in grizabella/core/query_models.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
check_exclusive_fields(values)
classmethod
Ensure that either 'components' or 'query_root' is provided, but not both.
Source code in grizabella/core/query_models.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
EmbeddingSearchClause
Bases: BaseModel
Defines a search based on embedding similarity.
This clause is used within a QueryComponent to find objects that are
semantically similar to a given query vector, based on pre-computed
embeddings.
Attributes:
| Name | Type | Description |
|---|---|---|
embedding_definition_name |
str
|
:noindex: The name of the |
similar_to_payload |
List[float]
|
:noindex: The embedding vector to find
similarities against. This vector should have the same dimensions
as specified in the |
threshold |
Optional[float]
|
:noindex: An optional similarity score threshold. Only results with a similarity score greater than or equal to this threshold will be returned. If None, no threshold is applied. |
limit |
int
|
:noindex: The maximum number of similar items to retrieve and consider from this clause. Defaults to 10. |
Source code in grizabella/core/query_models.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
EmbeddingVector
Bases: BaseModel
A container for a list of floats representing an embedding vector.
Source code in grizabella/core/query_models.py
374 375 376 377 | |
GraphTraversalClause
Bases: BaseModel
Defines a graph traversal condition from a source object set.
This clause is used within a QueryComponent to navigate relationships
in the graph database. It specifies the type of relation to follow,
the direction of traversal, and conditions on the target objects.
Attributes:
| Name | Type | Description |
|---|---|---|
relation_type_name |
str
|
:noindex: The name of the |
direction |
Literal['outgoing', 'incoming']
|
:noindex: The direction of the traversal from the current set of source objects. "outgoing" means following relations where the current objects are the source; "incoming" means following relations where they are the target. Defaults to "outgoing". |
target_object_type_name |
str
|
:noindex: The expected |
target_object_id |
Optional[UUID]
|
:noindex: An optional specific ID of a target object. If provided, the traversal will only consider paths leading to this specific object. |
target_object_properties |
Optional[List[RelationalFilter]]
|
:noindex: Optional
list of |
Source code in grizabella/core/query_models.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
LogicalGroup
Bases: BaseModel
Represents a group of query clauses combined by a single logical operator.
Source code in grizabella/core/query_models.py
277 278 279 280 281 282 283 284 285 286 287 | |
LogicalOperator
Bases: str, Enum
Defines the logical operators for combining query clauses.
Source code in grizabella/core/query_models.py
270 271 272 273 274 | |
NotClause
Bases: BaseModel
Represents a logical NOT operation on a single query clause.
Source code in grizabella/core/query_models.py
290 291 292 293 294 295 296 | |
QueryComponent
Bases: BaseModel
Defines a single logical block of query conditions targeting a primary object type.
A QueryComponent groups various types of search and filter conditions
that apply to a specific ObjectTypeDefinition. All conditions
(relational filters, embedding searches, graph traversals) specified
within a single component are implicitly ANDed together. The results
from these conditions are intersected to produce a set of matching
ObjectInstances of the object_type_name.
Attributes:
| Name | Type | Description |
|---|---|---|
object_type_name |
str
|
:noindex: The primary |
relational_filters |
Optional[List[RelationalFilter]]
|
:noindex: A list of
|
embedding_searches |
Optional[List[EmbeddingSearchClause]]
|
:noindex: A list of
|
graph_traversals |
Optional[List[GraphTraversalClause]]
|
:noindex: A list of
|
Source code in grizabella/core/query_models.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
QueryResult
Bases: BaseModel
Represents the result of a complex query execution.
This model encapsulates the ObjectInstances that match the criteria
of a ComplexQuery, along with any errors that may have occurred during
the query planning or execution process.
Attributes:
| Name | Type | Description |
|---|---|---|
object_instances |
List[ObjectInstance]
|
:noindex: A list of |
errors |
Optional[List[str]]
|
:noindex: A list of error messages encountered during the execution of the query. If the query was successful, this will be None or an empty list. |
Source code in grizabella/core/query_models.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
RelationalFilter
Bases: BaseModel
Defines a filter condition based on an object's property value.
This model is used within QueryComponent and GraphTraversalClause
to specify conditions for filtering objects based on their properties.
It allows for various comparison operators against a given value.
Attributes:
| Name | Type | Description |
|---|---|---|
property_name |
str
|
:noindex: The name of the property on which to apply the filter.
This must match a property defined in the relevant |
operator |
Literal
|
:noindex: The comparison operator to use. Supported operators include "==", "!=", ">", "<", ">=", "<=", "LIKE", "IN", "CONTAINS", "STARTSWITH", and "ENDSWITH". |
value |
FilterValueType
|
:noindex: The value to compare the property against. The type of this value should be compatible with the data type of the specified property. For "IN" operator, this should be a list of values. |
Source code in grizabella/core/query_models.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |