SearchIndex¶
API reference¶
synapseclient.models.SearchIndex
dataclass
¶
Bases: SearchIndexSynchronousProtocol, AccessControllable, DeleteMixin, GetMixin
A SearchIndex is a Synapse entity whose content is defined by a Synapse SQL
query (defining_sql). An OpenSearch index is built from the query results,
supporting full-text search, faceted search, and autocomplete.
The defining_sql must reference exactly one table-like entity. Multi-entity
JOIN/UNION queries are not supported. Optionally, a search_configuration_id
may be supplied to control the analyzer/synonym settings used when building
the index. If not specified, the configuration is resolved by walking up
the entity hierarchy.
REST API model: https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/search/table/SearchIndex.html
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The unique immutable ID for this entity. |
name |
The name of this entity. |
description |
The description of this entity. |
etag |
Synapse OCC etag. |
created_on |
Date this entity was created. |
modified_on |
Date this entity was last modified. |
created_by |
The ID of the user that created this entity. |
modified_by |
The ID of the user that last modified this entity. |
parent_id |
The ID of the parent entity. |
defining_sql |
The Synapse SQL statement that defines which columns and rows are indexed. |
search_configuration_id |
ID of the SearchConfiguration to apply when building this index. Optional. |
annotations |
Additional metadata associated with the entity.
TYPE:
|
activity |
Provenance for this entity. |
Create a new SearchIndex.
from synapseclient import Synapse
from synapseclient.models import SearchIndex
syn = Synapse()
syn.login()
index = SearchIndex(
name="My Search Index",
parent_id="syn12345",
# syn67890 must be a table or a view; multi-entity JOINs are not supported
defining_sql="SELECT * FROM syn67890",
)
index = index.store()
print(f"Created SearchIndex: {index.id}")
Source code in synapseclient/models/search_index.py
46 47 48 49 50 51 52 53 54 55 56 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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 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 212 213 214 215 216 217 218 219 220 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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 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 340 341 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 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | |
Methods:¶
store_async
async
¶
Asynchronously store the SearchIndex entity. Creates a new SearchIndex
if id is not set, or updates the existing one otherwise. defining_sql
must be set before calling this.
| PARAMETER | DESCRIPTION |
|---|---|
dry_run
|
If True, will not actually store the SearchIndex but will log to the console what would be created or updated.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Self
|
Itself. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Create a new SearchIndex.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SearchIndex
async def main():
syn = Synapse()
syn.login()
index = SearchIndex(
name="My Search Index",
parent_id="syn12345",
# syn67890 must be a table or a view;
defining_sql="SELECT * FROM syn67890",
)
index = await index.store_async()
print(f"Created SearchIndex: {index.id}")
asyncio.run(main())
Source code in synapseclient/models/search_index.py
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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 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 | |
get_async
async
¶
Asynchronously fetch the SearchIndex metadata. Either id, or name
and parent_id, must be set before calling this.
| PARAMETER | DESCRIPTION |
|---|---|
include_activity
|
If True, will include the provenance activity on the returned SearchIndex.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Self
|
Itself, populated from the Synapse response. |
Get a SearchIndex by ID.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SearchIndex
async def main():
syn = Synapse()
await syn.login_async()
index = await SearchIndex(id="syn12345").get_async()
print(index.name, index.defining_sql)
asyncio.run(main())
Source code in synapseclient/models/search_index.py
333 334 335 336 337 338 339 340 341 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 368 369 370 371 372 373 374 | |
delete_async
async
¶
Asynchronously delete this SearchIndex from Synapse. id must be set
before calling this.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
Delete a SearchIndex by ID.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SearchIndex
async def main():
syn = Synapse()
await syn.login_async()
await SearchIndex(id="syn12345").delete_async()
asyncio.run(main())
Source code in synapseclient/models/search_index.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
query_async
async
¶
query_async(search_query: SearchQuery, response_parts: Optional[List[SearchQueryPart]] = None, *, job_timeout: int = 600, synapse_client: Optional[Synapse] = None) -> SearchIndexQuery
Asynchronously query this search index. Unlike a SQL-backed Table, a SearchIndex is queried with the OpenSearch Query DSL carried by a SearchQuery — not with Synapse SQL. See Query for the supported clause kinds.
| PARAMETER | DESCRIPTION |
|---|---|
search_query
|
The OpenSearch
TYPE:
|
response_parts
|
Additional response parts to request beyond the default hits, such as the total hit count or the select columns.
TYPE:
|
job_timeout
|
The maximum amount of time to wait for the query job to
complete before raising a
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
SearchIndexQuery
|
The completed SearchIndexQuery, carrying the |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Query an index for documents mentioning "alzheimer".
import asyncio
from synapseclient import Synapse
from synapseclient.models import SearchIndex, SearchQuery, SearchQueryPart
from synapseclient.models.search_dsl import Query
async def main():
syn = Synapse()
await syn.login_async()
results = await SearchIndex(id="syn12345").query_async(
search_query=SearchQuery(
query=Query(match={"title": {"query": "alzheimer"}}),
size=10,
),
response_parts=[SearchQueryPart.TOTAL_HITS],
)
print(results.total_hits)
for hit in results.hits:
print(hit.row_id, hit.fields)
asyncio.run(main())
Source code in synapseclient/models/search_index.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
autocomplete_async
async
¶
autocomplete_async(query: Query, source: Optional[SourceFilter] = None, *, synapse_client: Optional[Synapse] = None) -> List[SearchHit]
Run a synchronous autocomplete search against this index. The
autocomplete endpoint allow lists only prefix-style queries
(prefix,
match_phrase_prefix,
or match_bool_prefix)
and caps results at 8.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
The top-level OpenSearch Query DSL
clause -- see Query;
restricted server-side to
TYPE:
|
source
|
Optional source filter selecting which columns are returned on each hit.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
List[SearchHit]
|
The matching SearchHits, capped at 8. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Autocomplete titles beginning with "alz".
import asyncio
from synapseclient import Synapse
from synapseclient.models import SearchIndex
from synapseclient.models.search_dsl import PrefixFieldOptions, Query
async def main():
syn = Synapse()
await syn.login_async()
index = SearchIndex(id="syn12345")
hits = await index.autocomplete_async(
query=Query(
prefix={"title": PrefixFieldOptions(value="alz")}
),
)
for hit in hits:
print(hit.row_id, hit.fields)
asyncio.run(main())
Source code in synapseclient/models/search_index.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | |
get_permissions_async
async
¶
get_permissions_async(*, synapse_client: Optional[Synapse] = None) -> Permissions
Get the permissions that the caller has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Permissions
|
A Permissions object |
Using this function:
Getting permissions for a Synapse Entity
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
permissions = await File(id="syn123").get_permissions_async()
asyncio.run(main())
Getting access types list from the Permissions object
permissions.access_types
Source code in synapseclient/models/mixins/access_control.py
210 211 212 213 214 215 216 217 218 219 220 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 | |
get_acl_async
async
¶
get_acl_async(principal_id: int = None, check_benefactor: bool = True, *, synapse_client: Optional[Synapse] = None) -> List[str]
Get the ACL that a user or group has on an Entity.
Note: If the entity does not have local sharing settings, or ACL set directly on it, this will look up the ACL on the benefactor of the entity. The benefactor is the entity that the current entity inherits its permissions from. The benefactor is usually the parent entity, but it can be any ancestor in the hierarchy. For example, a newly created Project will be its own benefactor, while a new FileEntity's benefactor will start off as its containing Project or Folder. If the entity already has local sharing settings, the benefactor would be itself.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group (defaults to PUBLIC users)
TYPE:
|
check_benefactor
|
If True (default), check the benefactor for the entity to get the ACL. If False, only check the entity itself. This is useful for checking the ACL of an entity that has local sharing settings, but you want to check the ACL of the entity itself and not the benefactor it may inherit from.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
An array containing some combination of ['READ', 'UPDATE', 'CREATE', 'DELETE', 'DOWNLOAD', 'MODERATE', 'CHANGE_PERMISSIONS', 'CHANGE_SETTINGS'] or an empty array |
Source code in synapseclient/models/mixins/access_control.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
set_permissions_async
async
¶
set_permissions_async(principal_id: int = None, access_type: List[str] = None, modify_benefactor: bool = False, warn_if_inherits: bool = True, overwrite: bool = True, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, list]]
Sets permission that a user or group has on an Entity. An Entity may have its own ACL or inherit its ACL from a benefactor.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group.
TYPE:
|
access_type
|
Type of permission to be granted. One or more of CREATE, READ, DOWNLOAD, UPDATE, DELETE, CHANGE_PERMISSIONS. Defaults to ['READ', 'DOWNLOAD'] |
modify_benefactor
|
Set as True when modifying a benefactor's ACL. The term 'benefactor' is used to indicate which Entity an Entity inherits its ACL from. For example, a newly created Project will be its own benefactor, while a new FileEntity's benefactor will start off as its containing Project. If the entity already has local sharing settings the benefactor would be itself. It may also be the immediate parent, somewhere in the parent tree, or the project itself.
TYPE:
|
warn_if_inherits
|
When
TYPE:
|
overwrite
|
By default this function overwrites existing permissions for the specified user. Set this flag to False to add new permissions non-destructively.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, list]]
|
An Access Control List object matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/AccessControlList.html. |
Setting permissions
Grant all registered users download access
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
await File(id="syn123").set_permissions_async(principal_id=273948, access_type=['READ','DOWNLOAD'])
asyncio.run(main())
Grant the public view access
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
await File(id="syn123").set_permissions_async(principal_id=273949, access_type=['READ'])
asyncio.run(main())
Source code in synapseclient/models/mixins/access_control.py
303 304 305 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 340 341 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 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
delete_permissions_async
async
¶
delete_permissions_async(include_self: bool = True, include_container_content: bool = False, recursive: bool = False, target_entity_types: Optional[List[str]] = None, dry_run: bool = False, show_acl_details: bool = True, show_files_in_containers: bool = True, *, synapse_client: Optional[Synapse] = None, _benefactor_tracker: Optional[BenefactorTracker] = None) -> None
Delete the entire Access Control List (ACL) for a given Entity. This is not scoped to a specific user or group, but rather removes all permissions associated with the Entity. After this operation, the Entity will inherit permissions from its benefactor, which is typically its parent entity or the Project it belongs to.
In order to remove permissions for a specific user or group, you
should use the set_permissions_async method with the access_type set to
an empty list.
By default, Entities such as FileEntity and Folder inherit their permission from their containing Project. For such Entities the Project is the Entity's 'benefactor'. This permission inheritance can be overridden by creating an ACL for the Entity. When this occurs the Entity becomes its own benefactor and all permission are determined by its own ACL.
If the ACL of an Entity is deleted, then its benefactor will automatically be set to its parent's benefactor.
Special notice for Projects: The ACL for a Project cannot be deleted, you must individually update or revoke the permissions for each user or group.
| PARAMETER | DESCRIPTION |
|---|---|
include_self
|
If True (default), delete the ACL of the current entity. If False, skip deleting the ACL of the current entity.
TYPE:
|
include_container_content
|
If True, delete ACLs from contents directly within containers (files and folders inside self). This must be set to True for recursive to have any effect. Defaults to False.
TYPE:
|
recursive
|
If True and the entity is a container (e.g., Project or Folder),
recursively process child containers. Note that this must be used with
include_container_content=True to have any effect. Setting recursive=True
with include_container_content=False will raise a ValueError.
Only works on classes that support the
TYPE:
|
target_entity_types
|
Specify which entity types to process when deleting ACLs.
Allowed values are "folder", "file", "project", "table", "entityview",
"materializedview", "virtualtable", "dataset", "datasetcollection",
"submissionview" (case-insensitive). If None, defaults to ["folder", "file"].
This does not affect the entity type of the current entity, which is always
processed if |
dry_run
|
If True, log the changes that would be made instead of actually performing the deletions. When enabled, all ACL deletion operations are simulated and logged at info level. Defaults to False.
TYPE:
|
show_acl_details
|
When dry_run=True, controls whether current ACL details are displayed for entities that will have their permissions changed. If True (default), shows detailed ACL information. If False, hides ACL details for cleaner output. Has no effect when dry_run=False.
TYPE:
|
show_files_in_containers
|
When dry_run=True, controls whether files within containers are displayed in the preview. If True (default), shows all files. If False, hides files when their only change is benefactor inheritance (but still shows files with local ACLs being deleted). Has no effect when dry_run=False.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
_benefactor_tracker
|
Internal use tracker for managing benefactor relationships. Used for recursive functionality to track which entities will be affected
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the entity does not have an ID or if an invalid entity type is provided. |
SynapseHTTPError
|
If there are permission issues or if the entity already inherits permissions. |
Exception
|
For any other errors that may occur during the process. |
Note: The caller must be granted ACCESS_TYPE.CHANGE_PERMISSIONS on the Entity to call this method.
Delete permissions for a single entity
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
await File(id="syn123").delete_permissions_async()
asyncio.run(main())
Delete permissions recursively for a folder and all its children
import asyncio
from synapseclient import Synapse
from synapseclient.models import Folder
syn = Synapse()
syn.login()
async def main():
# Delete permissions for this folder only (does not affect children)
await Folder(id="syn123").delete_permissions_async()
# Delete permissions for all files and folders directly within this folder,
# but not the folder itself
await Folder(id="syn123").delete_permissions_async(
include_self=False,
include_container_content=True
)
# Delete permissions for all items in the entire hierarchy (folders and their files)
# Both recursive and include_container_content must be True
await Folder(id="syn123").delete_permissions_async(
recursive=True,
include_container_content=True
)
# Delete permissions only for folder entities within this folder recursively
# and their contents
await Folder(id="syn123").delete_permissions_async(
recursive=True,
include_container_content=True,
target_entity_types=["folder"]
)
# Delete permissions only for files within this folder and all subfolders
await Folder(id="syn123").delete_permissions_async(
include_self=False,
recursive=True,
include_container_content=True,
target_entity_types=["file"]
)
# Delete permissions for specific entity types (e.g., tables and views)
await Folder(id="syn123").delete_permissions_async(
recursive=True,
include_container_content=True,
target_entity_types=["table", "entityview", "materializedview"]
)
# Dry run example: Log what would be deleted without making changes
await Folder(id="syn123").delete_permissions_async(
recursive=True,
include_container_content=True,
dry_run=True
)
asyncio.run(main())
Source code in synapseclient/models/mixins/access_control.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | |
list_acl_async
async
¶
list_acl_async(recursive: bool = False, include_container_content: bool = False, target_entity_types: Optional[List[str]] = None, log_tree: bool = False, *, synapse_client: Optional[Synapse] = None, _progress_bar: Optional[tqdm] = None) -> AclListResult
List the Access Control Lists (ACLs) for this entity and optionally its children.
This function returns the local sharing settings for the entity and optionally its children. It provides a mapping of all ACLs for the given container/entity.
Important Note: This function returns the LOCAL sharing settings only, not the effective permissions that each Synapse User ID/Team has on the entities. More permissive permissions could be granted via a Team that the user has access to that has permissions on the entity, or through inheritance from parent entities.
| PARAMETER | DESCRIPTION |
|---|---|
recursive
|
If True and the entity is a container (e.g., Project or Folder),
recursively process child containers. Note that this must be used with
include_container_content=True to have any effect. Setting recursive=True
with include_container_content=False will raise a ValueError.
Only works on classes that support the
TYPE:
|
include_container_content
|
If True, include ACLs from contents directly within containers (files and folders inside self). This must be set to True for recursive to have any effect. Defaults to False.
TYPE:
|
target_entity_types
|
Specify which entity types to process when listing ACLs. Allowed values are "folder", "file", "project", "table", "entityview", "materializedview", "virtualtable", "dataset", "datasetcollection", "submissionview" (case-insensitive). If None, defaults to ["folder", "file"]. |
log_tree
|
If True, logs the ACL results to console in ASCII tree format showing entity hierarchies and their ACL permissions in a tree-like structure. Defaults to False.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
_progress_bar
|
Internal parameter. Progress bar instance to use for updates when called recursively. Should not be used by external callers.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AclListResult
|
An AclListResult object containing a structured representation of ACLs where: |
AclListResult
|
|
AclListResult
|
|
AclListResult
|
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the entity does not have an ID or if an invalid entity type is provided. |
SynapseHTTPError
|
If there are permission issues accessing ACLs. |
Exception
|
For any other errors that may occur during the process. |
List ACLs for a single entity
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
acl_result = await File(id="syn123").list_acl_async()
print(acl_result)
# Access entity ACLs (entity_acls is a list, not a dict)
for entity_acl in acl_result.all_entity_acls:
if entity_acl.entity_id == "syn123":
# Access individual ACL entries
for acl_entry in entity_acl.acl_entries:
if acl_entry.principal_id == "273948":
print(f"Principal 273948 has permissions: {acl_entry.permissions}")
# I can also access the ACL for the file itself
print(acl_result.entity_acl)
print(acl_result)
asyncio.run(main())
List ACLs recursively for a folder and all its children
import asyncio
from synapseclient import Synapse
from synapseclient.models import Folder
syn = Synapse()
syn.login()
async def main():
acl_result = await Folder(id="syn123").list_acl_async(
recursive=True,
include_container_content=True
)
# Access each entity's ACL (entity_acls is a list)
for entity_acl in acl_result.all_entity_acls:
print(f"Entity {entity_acl.entity_id} has ACL with {len(entity_acl.acl_entries)} principals")
# I can also access the ACL for the folder itself
print(acl_result.entity_acl)
# List ACLs for only folder entities
folder_acl_result = await Folder(id="syn123").list_acl_async(
recursive=True,
include_container_content=True,
target_entity_types=["folder"]
)
# List ACLs for specific entity types (e.g., tables and views)
table_view_acl_result = await Folder(id="syn123").list_acl_async(
recursive=True,
include_container_content=True,
target_entity_types=["table", "entityview", "materializedview"]
)
asyncio.run(main())
List ACLs with ASCII tree visualization
When log_tree=True, the ACLs will be logged in a tree format. Additionally,
the ascii_tree attribute of the AclListResult will contain the ASCII tree
representation of the ACLs.
import asyncio
from synapseclient import Synapse
from synapseclient.models import Folder
syn = Synapse()
syn.login()
async def main():
acl_result = await Folder(id="syn123").list_acl_async(
recursive=True,
include_container_content=True,
log_tree=True, # Enable ASCII tree logging
)
# The ASCII tree representation of the ACLs will also be available
# in acl_result.ascii_tree
print(acl_result.ascii_tree)
asyncio.run(main())
Source code in synapseclient/models/mixins/access_control.py
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 | |
Supporting types¶
synapseclient.models.SearchQuery
dataclass
¶
The body of an OpenSearch _search
request, narrowed to the top-level keys Synapse accepts. Each slot's
contents are pass-through OpenSearch query DSL,
typed by the TypedDict shapes in synapseclient.models.search_dsl.
Represents a Synapse SearchQuery.
Source code in synapseclient/models/search_management.py
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 | |
Attributes¶
query
class-attribute
instance-attribute
¶
Required. The OpenSearch query DSL
clause -- see Query for every
supported clause kind. Use {"match_all": {}}
to match all documents. See also
query vs. filter context.
post_filter
class-attribute
instance-attribute
¶
Optional. Same DSL shape as query (see
Query), applied after
aggregations are computed. For the distinction between filtering hits and
filtering aggregations, see
query vs. filter context.
aggregations
class-attribute
instance-attribute
¶
aggregations: Optional[Dict[str, Aggregation]] = None
Optional. Map of caller-chosen name to
aggregation definition. The
raw aggregation result comes back on SearchIndexQuery.aggregation_results.
For the facet-counting pattern (a terms aggregation alongside
post_filter), see the
faceted search tutorial.
highlight
class-attribute
instance-attribute
¶
Optional. Adds per-field
snippet fragments
(matched terms wrapped in <em> / </em> by default) to each hit's
highlights.
collapse
class-attribute
instance-attribute
¶
collapse: Optional[FieldCollapse] = None
Optional. Groups the result list so only one hit is returned per distinct value of a field.
rescore
class-attribute
instance-attribute
¶
Optional. Re-ranks
the top hits returned by query using a secondary scoring query.
sort
class-attribute
instance-attribute
¶
Optional. Result ordering,
in native OpenSearch sort shape (a string column name,
{column: "asc|desc"}, or {column: {order: ..., mode: ..., missing: ...}})
applied in order. Only the field and _score sort kinds are accepted --
script and geo-distance sorts are rejected server-side. The pseudo-column
_score sorts by relevance. When omitted, results are sorted by relevance
descending.
source
class-attribute
instance-attribute
¶
source: Optional[SourceFilter] = None
Optional. Source filter
selecting which columns are returned on each hit. Serialized as
_source.
from_
class-attribute
instance-attribute
¶
Optional. Zero-based
pagination
offset; default 0. Ignored when search_after is supplied. Serialized as
from.
synapseclient.models.SearchQueryPart
¶
Optional response parts for a SearchQuery beyond default HITS.
These are values for the responseParts field on a SearchIndexQuery.
Source code in synapseclient/models/search_management.py
75 76 77 78 79 80 81 82 83 | |
synapseclient.models.SearchIndexQuery
dataclass
¶
Bases: AsynchronousCommunicator
An async request to query a SearchIndex's OpenSearch index.
Inherits from AsynchronousCommunicator: call send_job_and_wait_async() to
submit the job, poll the Synapse async job service, and populate response
fields (hits, total_hits, select_columns, aggregation_results,
next_search_after, offset) on this same instance.
The search_query body is an OpenSearch
_search
request -- see SearchQuery for the
allowlisted top-level keys and
Query for the
query DSL clause kinds.
Represents a Synapse SearchIndexQuery.
Run a search query.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SearchIndexQuery, SearchQuery, SearchQueryPart
async def main():
Synapse().login()
query = SearchIndexQuery(
search_index_id="syn22806626",
search_query=SearchQuery(
query={"match": {"title": {"query": "alzheimer"}}},
size=10,
),
response_parts=[SearchQueryPart.HITS, SearchQueryPart.TOTAL_HITS],
)
await query.send_job_and_wait_async()
print(query.total_hits, len(query.hits))
asyncio.run(main())
Source code in synapseclient/models/search_management.py
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 | |
Attributes¶
concrete_type
class-attribute
instance-attribute
¶
concrete_type: str = concrete_types.SEARCH_INDEX_QUERY
The Synapse concrete type identifying this async request.
search_index_id
class-attribute
instance-attribute
¶
The ID of the SearchIndex entity to query.
search_query
class-attribute
instance-attribute
¶
search_query: Optional[SearchQuery] = None
The SearchQuery (OpenSearch _search body) to execute against the index.
response_parts
class-attribute
instance-attribute
¶
response_parts: Optional[List[SearchQueryPart]] = field(default_factory=list)
Optional list of additional response parts beyond default HITS.
hits
class-attribute
instance-attribute
¶
Response: matching documents. Populated after send_job_and_wait_async().
total_hits
class-attribute
instance-attribute
¶
Response: total number of matching documents. Populated when SearchQueryPart.TOTAL_HITS is requested.
select_columns
class-attribute
instance-attribute
¶
select_columns: Optional[List[SelectColumn]] = field(default_factory=list)
Response: columns represented in each hit's fields, in SELECT-clause order. Populated when SearchQueryPart.SELECT_COLUMNS is requested.
aggregation_results
class-attribute
instance-attribute
¶
Response: the raw OpenSearch
aggregations response,
with field references rewritten back to column names. Populated whenever the
request supplied search_query.aggregations. Kept as an opaque JSON object
because its shape mirrors whichever aggregations were requested.
synapseclient.models.SearchAutocompleteRequest
dataclass
¶
Body of a synchronous autocomplete request against a SearchIndex. The
autocomplete endpoint allowlists only query (restricted to
prefix,
match_phrase_prefix,
or match_bool_prefix)
and _source.
Represents a Synapse SearchAutocompleteRequest.
Source code in synapseclient/models/search_management.py
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 | |
Attributes¶
search_index_id
class-attribute
instance-attribute
¶
The ID of the SearchIndex entity to query.
query
class-attribute
instance-attribute
¶
Required. The top-level
Query DSL clause; restricted
server-side to prefix, match_phrase_prefix, or
match_bool_prefix.
source
class-attribute
instance-attribute
¶
source: Optional[SourceFilter] = None
Optional. Source filter;
same shape as SearchQuery.source. Serialized as _source.
synapseclient.models.SearchHit
dataclass
¶
A single matching document in a SearchQueryResults response.
Represents a Synapse SearchHit.
Source code in synapseclient/models/search_management.py
1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 | |
Attributes¶
row_id
class-attribute
instance-attribute
¶
The row ID from the source table.
row_version
class-attribute
instance-attribute
¶
The row version from the source table.
score
class-attribute
instance-attribute
¶
The relevance score for this hit.
synapseclient.models.SearchFieldValue
dataclass
¶
A name/value pair returned in a SearchHit's fields.
Represents a Synapse SearchFieldValue.
Source code in synapseclient/models/search_management.py
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 | |
synapseclient.models.SearchHighlight
dataclass
¶
A per-field highlight payload on a SearchHit.
Represents a Synapse SearchHighlight.
Source code in synapseclient/models/search_management.py
1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 | |
Attributes¶
OpenSearch query DSL¶
synapseclient.models.search_dsl.Query
¶
Bases: TypedDict
A single OpenSearch query DSL clause. Exactly one of the keys below may be set -- the set key names the clause kind. See query vs. filter context and term-level vs. full-text queries.
The field-keyed leaf clauses (match, term, range, ...) are maps whose
key is the column name and whose value is the per-field options object --
only the long form is accepted (e.g. {"match": {"title": {"query": "x"}}},
not the {"match": {"title": "x"}} shorthand). The compound clauses
(bool, dis_max, ...) nest further Query DSL clauses recursively.
Source code in synapseclient/models/search_dsl.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
Attributes¶
match
instance-attribute
¶
match: Dict[str, MatchFieldOptions]
A match
full-text clause. Map of column name to its match options.
match_phrase
instance-attribute
¶
match_phrase: Dict[str, MatchPhraseFieldOptions]
A match_phrase
clause. Map of column name to its phrase options.
match_phrase_prefix
instance-attribute
¶
match_phrase_prefix: Dict[str, MatchPhrasePrefixFieldOptions]
A match_phrase_prefix
clause. Map of column name to its options.
match_bool_prefix
instance-attribute
¶
match_bool_prefix: Dict[str, MatchBoolPrefixFieldOptions]
A match_bool_prefix
clause. Map of column name to its options.
term
instance-attribute
¶
term: Dict[str, TermFieldOptions]
A term
term-level clause. Map of column name to its term options.
range
instance-attribute
¶
range: Dict[str, RangeFieldOptions]
A range
term-level clause. Map of column name to its range bounds.
prefix
instance-attribute
¶
prefix: Dict[str, PrefixFieldOptions]
A prefix
term-level clause. Map of column name to its prefix options.
wildcard
instance-attribute
¶
wildcard: Dict[str, WildcardFieldOptions]
A wildcard
term-level clause. Map of column name to its wildcard options.
fuzzy
instance-attribute
¶
fuzzy: Dict[str, FuzzyFieldOptions]
A fuzzy
term-level clause. Map of column name to its fuzzy options.
terms
instance-attribute
¶
A terms
term-level clause (matches any of several exact values). Field-keyed:
{"terms": {"<column>": [v1, v2], "boost": 1.0}}. The cross-index
terms-lookup form is rejected. Untyped because the column name is itself a
key alongside the fixed option keys, which a TypedDict cannot express; the
same allowlist is enforced server-side.
simple_query_string
instance-attribute
¶
simple_query_string: SimpleQueryStringQuery
A simple_query_string
full-text clause.
bool
instance-attribute
¶
bool: BoolQuery
A bool
compound clause -- combines sub-clauses with boolean logic.
constant_score
instance-attribute
¶
constant_score: ConstantScoreQuery
A constant_score
compound clause.
Leaf clause field options¶
synapseclient.models.search_dsl.MatchFieldOptions
¶
Bases: ClauseScoringOptions, FuzzyMatchOptions, MinimumShouldMatchOption, ZeroTermsQueryOption
Per-field options for a match
full-text clause. Carried as the value of the field-keyed match map (the
map key is the column name).
Source code in synapseclient/models/search_dsl.py
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 | |
Attributes¶
query
instance-attribute
¶
query: ScalarValue
Required. The text (or scalar value on a non-text column) to match. A string, number, or boolean depending on the target column type.
operator
instance-attribute
¶
operator: str
Optional. Boolean logic used to combine the analyzed query terms: or
(default) or and.
analyzer
instance-attribute
¶
analyzer: str
Optional. Analyzer used to tokenize the query text. Defaults to the field's search analyzer.
max_expansions
instance-attribute
¶
max_expansions: int
Optional. Maximum number of terms the fuzzy expansion will generate.
cutoff_frequency
instance-attribute
¶
cutoff_frequency: float
Optional. Term-frequency threshold above which terms are treated as low-importance.
synapseclient.models.search_dsl.MatchPhraseFieldOptions
¶
Bases: ClauseScoringOptions, ZeroTermsQueryOption
Per-field options for a match_phrase
clause. Carried as the value of the field-keyed match_phrase map (the map
key is the column name).
Source code in synapseclient/models/search_dsl.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
synapseclient.models.search_dsl.MatchPhrasePrefixFieldOptions
¶
Bases: ClauseScoringOptions, ZeroTermsQueryOption
Per-field options for a match_phrase_prefix
clause. Carried as the value of the field-keyed match_phrase_prefix map
(the map key is the column name).
Source code in synapseclient/models/search_dsl.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
Attributes¶
query
instance-attribute
¶
query: ScalarValue
Required. The phrase whose last term is treated as a prefix. A string.
analyzer
instance-attribute
¶
analyzer: str
Optional. Analyzer used to tokenize the phrase. Defaults to the field's search analyzer.
synapseclient.models.search_dsl.MatchBoolPrefixFieldOptions
¶
Bases: ClauseScoringOptions, FuzzyMatchOptions, MinimumShouldMatchOption
Per-field options for a match_bool_prefix
clause. Carried as the value of the field-keyed match_bool_prefix map
(the map key is the column name).
Source code in synapseclient/models/search_dsl.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
Attributes¶
query
instance-attribute
¶
query: ScalarValue
Required. The text whose terms are matched, with the final term treated as a prefix. A string.
operator
instance-attribute
¶
operator: str
Optional. Boolean logic used to combine the analyzed terms: or
(default) or and.
synapseclient.models.search_dsl.TermFieldOptions
¶
Bases: ClauseScoringOptions
Per-field options for a term
term-level clause (exact, non-analyzed match). Carried as the value of the
field-keyed term map (the map key is the column name).
Source code in synapseclient/models/search_dsl.py
196 197 198 199 200 201 202 203 204 205 206 207 | |
synapseclient.models.search_dsl.RangeFieldOptions
¶
Bases: ClauseScoringOptions
Per-field options for a range
term-level clause. Carried as the value of the field-keyed range map (the
map key is the column name).
Source code in synapseclient/models/search_dsl.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
Attributes¶
gte
instance-attribute
¶
gte: ScalarValue
Optional. Greater-than-or-equal-to bound. A number or date string, per the target column type.
format
instance-attribute
¶
format: str
Optional. Date format used to parse the bound values on a date column.
synapseclient.models.search_dsl.PrefixFieldOptions
¶
Bases: ClauseScoringOptions
Per-field options for a prefix
term-level clause. Carried as the value of the field-keyed prefix map
(the map key is the column name). A leading * or ? in value is
rejected (it forces a full index scan).
Source code in synapseclient/models/search_dsl.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
synapseclient.models.search_dsl.WildcardFieldOptions
¶
Bases: ClauseScoringOptions
Per-field options for a wildcard
term-level clause. Carried as the value of the field-keyed wildcard map
(the map key is the column name). A leading * or ? in the pattern is
rejected (it forces a full index scan).
Source code in synapseclient/models/search_dsl.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
Attributes¶
value
instance-attribute
¶
value: ScalarValue
Optional. The wildcard pattern (* matches any sequence, ? matches a
single character). A string. Either value or wildcard supplies the
pattern.
wildcard
instance-attribute
¶
wildcard: ScalarValue
Optional. Alias for value -- the wildcard pattern. A string.
synapseclient.models.search_dsl.FuzzyFieldOptions
¶
Bases: ClauseScoringOptions
Per-field options for a fuzzy
term-level clause. Carried as the value of the field-keyed fuzzy map (the
map key is the column name).
Source code in synapseclient/models/search_dsl.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
Attributes¶
value
instance-attribute
¶
value: ScalarValue
Required. The term to match within the allowed edit distance. A string (or scalar value on a non-text column).
fuzziness
instance-attribute
¶
Optional. Allowed edit distance:
an integer or AUTO.
max_expansions
instance-attribute
¶
max_expansions: int
Optional. Maximum number of terms the fuzzy expansion will generate.
Default 50.
prefix_length
instance-attribute
¶
prefix_length: int
Optional. Number of leading characters left unchanged when fuzzy matching.
synapseclient.models.search_dsl.ExistsQuery
¶
Bases: ClauseScoringOptions
An exists
term-level clause. Matches documents that have any non-null value for the
given column.
Source code in synapseclient/models/search_dsl.py
309 310 311 312 313 314 315 | |
synapseclient.models.search_dsl.MultiMatchQuery
¶
Bases: ClauseScoringOptions, FuzzyMatchOptions, MinimumShouldMatchOption, ZeroTermsQueryOption
A multi_match
full-text clause -- a match run across several columns at once.
Source code in synapseclient/models/search_dsl.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 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 368 369 | |
Attributes¶
query
instance-attribute
¶
query: ScalarValue
Required. The text to match across the listed columns. A string.
fields
instance-attribute
¶
Required. The columns to search. Each entry may carry a ^boost suffix
(e.g. title^2).
type
instance-attribute
¶
type: str
Optional. How the per-field matches are combined: best_fields
(default), most_fields, cross_fields, phrase, phrase_prefix, or
bool_prefix.
operator
instance-attribute
¶
operator: str
Optional. Boolean logic used to combine the analyzed terms: or
(default) or and.
tie_breaker
instance-attribute
¶
tie_breaker: float
Optional. Weight (0-1) applied to non-best field scores in
best_fields / cross_fields.
analyzer
instance-attribute
¶
analyzer: str
Optional. Analyzer used to tokenize the query text. Defaults to each field's search analyzer.
max_expansions
instance-attribute
¶
max_expansions: int
Optional. Maximum number of terms a fuzzy / prefix expansion will
generate. Default 50.
slop
instance-attribute
¶
slop: int
Optional. Number of positions allowed between matching terms for the phrase types.
cutoff_frequency
instance-attribute
¶
cutoff_frequency: float
Optional. Term-frequency threshold above which terms are treated as low-importance.
synapseclient.models.search_dsl.SimpleQueryStringQuery
¶
Bases: ClauseScoringOptions, MinimumShouldMatchOption
A simple_query_string
full-text clause -- a compact mini-DSL (+, |, -, ", *, ())
parsed leniently across the listed columns.
Source code in synapseclient/models/search_dsl.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
Attributes¶
fields
instance-attribute
¶
Optional. The columns to search. Each entry may carry a ^boost
suffix. Defaults to the index's default search fields.
default_operator
instance-attribute
¶
default_operator: str
Optional. Boolean logic used between terms when no explicit operator is
given: or (default) or and.
flags
instance-attribute
¶
flags: str
Optional. Pipe-delimited list of enabled syntax features (e.g.
AND|OR|PREFIX), or ALL / NONE.
analyzer
instance-attribute
¶
analyzer: str
Optional. Analyzer used to tokenize the query text. Defaults to each field's search analyzer.
analyze_wildcard
instance-attribute
¶
analyze_wildcard: bool
Optional. Whether to analyze wildcard terms. Default false. A leading
wildcard with this enabled is rejected (it forces a full index scan).
auto_generate_synonyms_phrase_query
instance-attribute
¶
auto_generate_synonyms_phrase_query: bool
Optional. Whether to auto-generate phrase queries for multi-term
synonyms. Default true.
fuzzy_max_expansions
instance-attribute
¶
fuzzy_max_expansions: int
Optional. Maximum number of terms a fuzzy expansion will generate.
Default 50.
fuzzy_prefix_length
instance-attribute
¶
fuzzy_prefix_length: int
Optional. Number of leading characters left unchanged when fuzzy matching.
synapseclient.models.search_dsl.MatchAllQuery
¶
Bases: ClauseScoringOptions
A match_all
clause. Matches every document. Use {"match_all": {}} to match all
documents.
Source code in synapseclient/models/search_dsl.py
426 427 428 429 | |
Compound clauses¶
synapseclient.models.search_dsl.BoolQuery
¶
Bases: ClauseScoringOptions
A bool
compound clause -- combines sub-clauses with boolean logic.
Source code in synapseclient/models/search_dsl.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
Attributes¶
should
instance-attribute
¶
Sub-clauses that should match (scored). See minimum_should_match.
must_not
instance-attribute
¶
Sub-clauses that must not match (filter context, not scored).
filter
instance-attribute
¶
Sub-clauses that must all match in filter context (not scored).
minimum_should_match
instance-attribute
¶
Optional. How many should clauses must match. An integer or a
percentage / formula string.
synapseclient.models.search_dsl.DisMaxQuery
¶
Bases: ClauseScoringOptions
A dis_max
compound clause. A document matches if any sub-clause matches; its score is
the best single sub-clause score plus tie_breaker times the rest.
Source code in synapseclient/models/search_dsl.py
459 460 461 462 463 464 465 466 467 468 469 | |
synapseclient.models.search_dsl.ConstantScoreQuery
¶
Bases: ClauseScoringOptions
A constant_score
compound clause. Wraps a filter and assigns every matching document the
same score (boost).
Source code in synapseclient/models/search_dsl.py
472 473 474 475 476 477 478 479 | |
Attributes¶
synapseclient.models.search_dsl.BoostingQuery
¶
Bases: ClauseScoringOptions
A boosting
compound clause. Returns documents matching positive, demoting those that
also match negative by negative_boost.
Source code in synapseclient/models/search_dsl.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
Attributes¶
Shared per-field option mixins¶
synapseclient.models.search_dsl.ClauseScoringOptions
¶
Bases: TypedDict
Scoring options shared by the OpenSearch query clauses: a relevance
boost and a _name label.
Source code in synapseclient/models/search_dsl.py
41 42 43 44 45 46 47 48 49 50 | |
synapseclient.models.search_dsl.FuzzyMatchOptions
¶
Bases: TypedDict
Fuzzy-matching parameters shared by the analyzed full-text match clauses
(match, match_bool_prefix, multi_match).
Source code in synapseclient/models/search_dsl.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
Attributes¶
fuzziness
instance-attribute
¶
Optional. Allowed edit distance:
an integer or AUTO.
fuzzy_rewrite
instance-attribute
¶
fuzzy_rewrite: str
Optional. How the fuzzy query is rewritten internally.
synapseclient.models.search_dsl.MinimumShouldMatchOption
¶
Bases: TypedDict
The minimum-should-match option shared by the analyzed full-text match clauses.
Source code in synapseclient/models/search_dsl.py
73 74 75 76 77 78 79 | |
synapseclient.models.search_dsl.ZeroTermsQueryOption
¶
Bases: TypedDict
The zero-terms-query behavior shared by the analyzed full-text match clauses.
Source code in synapseclient/models/search_dsl.py
82 83 84 85 86 87 88 | |
Aggregations¶
synapseclient.models.search_dsl.Aggregation
¶
Bases: TypedDict
A single OpenSearch aggregation
definition. Exactly one of the aggregation-kind keys below may be set;
aggregations may additionally carry nested sub-aggregations.
The filter and filters kinds wrap a
Query; that query is validated
identically to the top-level query and is scoped by it, so a filter
aggregation never counts documents outside the top-level query.
Source code in synapseclient/models/search_dsl.py
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | |
Attributes¶
date_histogram
instance-attribute
¶
date_histogram: DateHistogramAggregation
A date_histogram
bucket aggregation.
extended_stats
instance-attribute
¶
extended_stats: ExtendedStatsAggregation
An extended_stats
metric aggregation.
value_count
instance-attribute
¶
value_count: ValueCountAggregation
A value_count
metric aggregation.
cardinality
instance-attribute
¶
cardinality: CardinalityAggregation
A cardinality
metric aggregation.
filters
instance-attribute
¶
filters: FiltersAggregation
A filters
multi-bucket aggregation -- one named bucket per query.
aggregations
instance-attribute
¶
aggregations: Dict[str, Aggregation]
Optional. Nested sub-aggregations, keyed by caller-chosen name. Bucket aggregations compute these once per bucket.
synapseclient.models.search_dsl.TermsAggregation
¶
Bases: TypedDict
A terms
bucket aggregation -- one bucket per distinct value of field.
Source code in synapseclient/models/search_dsl.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | |
Attributes¶
size
instance-attribute
¶
size: int
Optional. Maximum number of buckets to return. Capped server-side.
shard_size
instance-attribute
¶
shard_size: int
Optional. Number of candidate buckets collected per shard before the final reduce. Capped server-side.
min_doc_count
instance-attribute
¶
min_doc_count: int
Optional. Minimum document count for a bucket to be returned. Default
1.
shard_min_doc_count
instance-attribute
¶
shard_min_doc_count: int
Optional. Per-shard minimum document count before a bucket is considered.
show_term_doc_count_error
instance-attribute
¶
show_term_doc_count_error: bool
Optional. Whether to return the per-bucket document-count error bound.
order
instance-attribute
¶
order: BucketOrder
Optional. Bucket sort order -- a {metric: "asc|desc"} object or an
array of them.
include
instance-attribute
¶
Optional. Terms to include -- a regex string or an array of exact values.
exclude
instance-attribute
¶
Optional. Terms to exclude -- a regex string or an array of exact values.
missing
instance-attribute
¶
missing: ScalarValue
Optional. Bucket value assigned to documents missing field.
collect_mode
instance-attribute
¶
collect_mode: str
Optional. breadth_first or depth_first sub-aggregation collection
strategy.
synapseclient.models.search_dsl.HistogramAggregation
¶
Bases: KeyedBucketOption, HistogramBoundsOptions
A histogram
bucket aggregation over a numeric column. Must specify extended_bounds or
hard_bounds so the bucket count is bounded.
Source code in synapseclient/models/search_dsl.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | |
Attributes¶
min_doc_count
instance-attribute
¶
min_doc_count: int
Optional. Minimum document count for a bucket to be returned.
order
instance-attribute
¶
order: BucketOrder
Optional. Bucket sort order -- a {metric: "asc|desc"} object or an
array of them.
missing
instance-attribute
¶
missing: ScalarValue
Optional. Bucket value assigned to documents missing field.
synapseclient.models.search_dsl.DateHistogramAggregation
¶
Bases: KeyedBucketOption, HistogramBoundsOptions
A date_histogram
bucket aggregation over a date column. Must specify extended_bounds or
hard_bounds so the bucket count is bounded.
Source code in synapseclient/models/search_dsl.py
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 | |
Attributes¶
calendar_interval
instance-attribute
¶
calendar_interval: str
Optional. Calendar-aware interval (e.g. month, year). Mutually
exclusive with fixed_interval.
fixed_interval
instance-attribute
¶
fixed_interval: str
Optional. Fixed-duration interval (e.g. 30d, 12h). Mutually
exclusive with calendar_interval.
interval
instance-attribute
¶
interval: str
Optional. Legacy interval (use calendar_interval / fixed_interval
instead).
min_doc_count
instance-attribute
¶
min_doc_count: int
Optional. Minimum document count for a bucket to be returned.
time_zone
instance-attribute
¶
time_zone: str
Optional. UTC offset or IANA zone used to compute bucket boundaries.
order
instance-attribute
¶
order: BucketOrder
Optional. Bucket sort order -- a {metric: "asc|desc"} object or an
array of them.
missing
instance-attribute
¶
missing: ScalarValue
Optional. Bucket value assigned to documents missing field.
synapseclient.models.search_dsl.RangeAggregation
¶
Bases: KeyedBucketOption
A range
bucket aggregation -- one bucket per caller-defined numeric range.
Source code in synapseclient/models/search_dsl.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
Attributes¶
ranges
instance-attribute
¶
Required. The bucket ranges,
each {"from": <lower>, "to": <upper>, "key": "<label>"} covering
[from, to). At least one of from / to is required per entry. Untyped
because from is a Python keyword and cannot be a TypedDict field.
missing
instance-attribute
¶
missing: ScalarValue
Optional. Value assigned to documents missing field.
synapseclient.models.search_dsl.DateRangeAggregation
¶
Bases: KeyedBucketOption
A date_range
bucket aggregation -- one bucket per caller-defined date range.
Source code in synapseclient/models/search_dsl.py
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | |
Attributes¶
ranges
instance-attribute
¶
Required. The bucket ranges,
each {"from": <lower>, "to": <upper>, "key": "<label>"}. Bound values may
be dates or date-math expressions. Untyped because from is a Python
keyword and cannot be a TypedDict field.
time_zone
instance-attribute
¶
time_zone: str
Optional. UTC offset or IANA zone used to interpret the range bounds.
missing
instance-attribute
¶
missing: ScalarValue
Optional. Value assigned to documents missing field.
synapseclient.models.search_dsl.MissingAggregation
¶
Bases: TypedDict
A missing
bucket aggregation -- a single bucket of documents that have no value for
field.
Source code in synapseclient/models/search_dsl.py
815 816 817 818 819 820 821 822 823 824 825 | |
synapseclient.models.search_dsl.MinAggregation
¶
Bases: MetricAggregation, MissingValueOption
A min
metric aggregation -- the minimum value of a numeric column.
Source code in synapseclient/models/search_dsl.py
828 829 830 831 832 833 834 | |
synapseclient.models.search_dsl.MaxAggregation
¶
Bases: MetricAggregation, MissingValueOption
A max
metric aggregation -- the maximum value of a numeric column.
Source code in synapseclient/models/search_dsl.py
837 838 839 840 841 842 843 | |
synapseclient.models.search_dsl.AvgAggregation
¶
Bases: MetricAggregation, MissingValueOption
An avg
metric aggregation -- the mean value of a numeric column.
Source code in synapseclient/models/search_dsl.py
846 847 848 849 850 851 852 | |
synapseclient.models.search_dsl.SumAggregation
¶
Bases: MetricAggregation, MissingValueOption
A sum
metric aggregation -- the sum of a numeric column.
Source code in synapseclient/models/search_dsl.py
855 856 857 | |
synapseclient.models.search_dsl.StatsAggregation
¶
Bases: MissingValueOption
A stats
metric aggregation -- count, min, max, avg, and sum of a numeric column in
one pass.
Source code in synapseclient/models/search_dsl.py
860 861 862 863 864 865 866 867 868 869 | |
synapseclient.models.search_dsl.ExtendedStatsAggregation
¶
Bases: MissingValueOption
An extended_stats
metric aggregation -- stats plus variance, standard deviation, and
standard-deviation bounds.
Source code in synapseclient/models/search_dsl.py
872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
synapseclient.models.search_dsl.ValueCountAggregation
¶
Bases: MissingValueOption
A value_count
metric aggregation -- the number of values extracted for a column.
Source code in synapseclient/models/search_dsl.py
888 889 890 891 892 893 894 895 896 | |
synapseclient.models.search_dsl.CardinalityAggregation
¶
Bases: MissingValueOption
A cardinality
metric aggregation -- an approximate distinct-value count of a column.
Source code in synapseclient/models/search_dsl.py
899 900 901 902 903 904 905 906 907 908 909 910 911 | |
synapseclient.models.search_dsl.FiltersAggregation
¶
Bases: TypedDict
A filters
multi-bucket aggregation. Each entry of filters is a named bucket whose
documents match its Query. The
named (keyed) form is the supported contract; each query is validated
identically to the top-level query and is scoped by it.
Source code in synapseclient/models/search_dsl.py
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | |
Attributes¶
filters
instance-attribute
¶
Required. Named buckets, keyed by caller-chosen name; each value is a Query selecting that bucket's documents.
other_bucket
instance-attribute
¶
other_bucket: bool
Optional. When true, adds a bucket for documents that match none of
the named filters.
synapseclient.models.search_dsl.ExtendedBounds
¶
Bases: TypedDict
Min/max bounds that force a histogram
or date_histogram
to emit buckets across the full range (used as extended_bounds or
hard_bounds). Bounding the range is what caps the bucket count.
Source code in synapseclient/models/search_dsl.py
588 589 590 591 592 593 594 595 596 597 598 599 600 | |
synapseclient.models.search_dsl.HistogramBoundsOptions
¶
Bases: TypedDict
The extended/hard bounds options shared by the histogram and
date_histogram aggregations.
Source code in synapseclient/models/search_dsl.py
603 604 605 606 607 608 609 610 611 612 | |
Attributes¶
extended_bounds
instance-attribute
¶
extended_bounds: ExtendedBounds
Optional. Forces buckets to span at least this min/max range.
hard_bounds
instance-attribute
¶
hard_bounds: ExtendedBounds
Optional. Restricts buckets to this min/max range (values outside are dropped).
synapseclient.models.search_dsl.KeyedBucketOption
¶
Bases: TypedDict
The keyed-output option shared by the bucketing aggregations.
Source code in synapseclient/models/search_dsl.py
615 616 617 618 619 620 | |
synapseclient.models.search_dsl.MetricAggregation
¶
Bases: TypedDict
Common options for the single-value numeric metric aggregations (avg,
max, min, sum).
Source code in synapseclient/models/search_dsl.py
623 624 625 626 627 628 629 630 631 | |
synapseclient.models.search_dsl.MissingValueOption
¶
Bases: TypedDict
The missing-value substitution option shared by the metric aggregations.
Source code in synapseclient/models/search_dsl.py
634 635 636 637 638 639 | |
Highlighting, source filtering, collapse, and rescore¶
synapseclient.models.search_dsl.Highlight
¶
Bases: HighlightCommonOptions
A highlight
block. Adds matched-term snippet fragments to each hit. Top-level options
apply to every highlighted field unless overridden in a per-field block
under fields.
Source code in synapseclient/models/search_dsl.py
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 | |
Attributes¶
fields
instance-attribute
¶
fields: Dict[str, HighlightField]
Required. The columns to highlight, keyed by column name; each value is its per-field option overrides.
type
instance-attribute
¶
type: str
Optional. Default highlighter implementation: unified (default),
plain, or fvh. The semantic highlighter is rejected.
number_of_fragments
instance-attribute
¶
number_of_fragments: int
Optional. Maximum number of fragments per field. Capped server-side.
encoder
instance-attribute
¶
encoder: str
Optional. How highlighted text is encoded: default or html.
pre_tags
instance-attribute
¶
Optional. Opening tags wrapped around highlighted terms. Default
<em>.
post_tags
instance-attribute
¶
Optional. Closing tags wrapped around highlighted terms. Default
</em>.
synapseclient.models.search_dsl.HighlightField
¶
Bases: HighlightCommonOptions
Per-field highlight
options, carried as the value of a
Highlight fields entry (the
map key is the column name). Any option set here overrides the top-level
highlight option for this field.
Source code in synapseclient/models/search_dsl.py
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 | |
Attributes¶
type
instance-attribute
¶
type: str
Optional. Highlighter implementation: unified (default), plain, or
fvh. The semantic highlighter is rejected.
number_of_fragments
instance-attribute
¶
number_of_fragments: int
Optional. Maximum number of fragments to return for this field. Capped server-side.
pre_tags
instance-attribute
¶
Optional. Opening tags wrapped around highlighted terms.
post_tags
instance-attribute
¶
Optional. Closing tags wrapped around highlighted terms.
matched_fields
instance-attribute
¶
Optional. Other fields whose matches also highlight this field (fvh
only).
synapseclient.models.search_dsl.HighlightCommonOptions
¶
Bases: TypedDict
Highlight options shared by the top-level highlight block and the per-field highlight overrides.
Source code in synapseclient/models/search_dsl.py
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 | |
Attributes¶
fragment_size
instance-attribute
¶
fragment_size: int
Optional. Maximum characters per highlighted fragment. Capped server-side.
fragment_offset
instance-attribute
¶
fragment_offset: int
Optional. Character offset at which to start highlighting (fvh
only).
no_match_size
instance-attribute
¶
no_match_size: int
Optional. Number of leading characters to return when there is no match.
fragmenter
instance-attribute
¶
fragmenter: str
Optional. Fragmentation strategy: simple or span (plain
highlighter).
boundary_scanner
instance-attribute
¶
boundary_scanner: str
Optional. Boundary detection: chars, sentence, or word.
boundary_scanner_locale
instance-attribute
¶
boundary_scanner_locale: str
Optional. Locale used by the boundary scanner.
boundary_chars
instance-attribute
¶
boundary_chars: str
Optional. Characters treated as boundaries by the chars scanner.
boundary_max_scan
instance-attribute
¶
boundary_max_scan: int
Optional. How far the boundary scanner looks for a boundary.
max_fragment_length
instance-attribute
¶
max_fragment_length: int
Optional. Maximum length of a fragment.
max_analyzer_offset
instance-attribute
¶
max_analyzer_offset: int
Optional. Maximum character offset analyzed for highlighting.
phrase_limit
instance-attribute
¶
phrase_limit: int
Optional. Maximum number of matching phrases considered (fvh
only).
require_field_match
instance-attribute
¶
require_field_match: bool
Optional. Whether only fields that matched the query are highlighted.
Default true.
highlight_filter
instance-attribute
¶
highlight_filter: bool
Optional. Whether to highlight only fields that passed the query filter.
synapseclient.models.search_dsl.SourceFilter
¶
Bases: TypedDict
A source filter
selecting which columns are returned on each hit. Carried as the
SearchQuery source field. Only this
typed {includes, excludes} form is accepted -- the boolean (true /
false) and bare-array shorthands are not.
Source code in synapseclient/models/search_dsl.py
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | |
synapseclient.models.search_dsl.FieldCollapse
¶
Bases: TypedDict
A collapse
block. Returns only the top hit per distinct value of field,
deduplicating the result list.
Source code in synapseclient/models/search_dsl.py
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 | |
synapseclient.models.search_dsl.Rescore
¶
Bases: TypedDict
A rescore stage.
Re-ranks the top window_size hits from the main query using a secondary
scoring query. A single stage is supported.
Source code in synapseclient/models/search_dsl.py
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | |
Attributes¶
window_size
instance-attribute
¶
window_size: int
Optional. Number of top hits per shard that are re-scored. Capped server-side.
query
instance-attribute
¶
query: RescoreQuery
Required. The secondary scoring query and how its score blends with the original.
synapseclient.models.search_dsl.RescoreQuery
¶
Bases: TypedDict
The secondary-scoring portion of a rescore stage: a query whose score is blended with the original score.
Source code in synapseclient/models/search_dsl.py
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 | |
Attributes¶
rescore_query
instance-attribute
¶
rescore_query: Query
Required. The query used to re-score the top window of hits.
query_weight
instance-attribute
¶
query_weight: float
Optional. Weight applied to the original query score. Default 1.0.