onyx-database 2.2.0__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {onyx_database-2.2.0 → onyx_database-2.3.0}/CHANGELOG.md +10 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/PKG-INFO +129 -3
- {onyx_database-2.2.0 → onyx_database-2.3.0}/README.md +128 -2
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx.schema.json +1 -1
- onyx_database-2.3.0/onyx_database/__init__.py +177 -0
- onyx_database-2.3.0/onyx_database/helpers/candidate_search.py +531 -0
- onyx_database-2.3.0/onyx_database/helpers/conditions.py +225 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/onyx.py +4 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/onyx_async.py +4 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/query_builder.py +126 -3
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/query_builder_async.py +110 -4
- onyx_database-2.3.0/onyx_database/types.py +171 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/pyproject.toml +1 -1
- {onyx_database-2.2.0 → onyx_database-2.3.0}/schema/onyx.schema.json +1 -1
- onyx_database-2.3.0/tests/test_candidate_search.py +558 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/test_entity_wire.py +69 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/test_search.py +16 -1
- onyx_database-2.2.0/onyx_database/__init__.py +0 -113
- onyx_database-2.2.0/onyx_database/helpers/conditions.py +0 -115
- onyx_database-2.2.0/onyx_database/types.py +0 -33
- {onyx_database-2.2.0 → onyx_database-2.3.0}/.github/workflows/ci.yml +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/.github/workflows/publish.yml +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/.gitignore +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/CONTRIBUTING.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/LICENSE +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/README.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/__init__.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/ai/chat.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/ai/chat_shorthand.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/ai/chat_shorthand_stream.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/ai/chat_stream.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/ai/models.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/ai/script_approval.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/ai/streaming.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/delete/by_id.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/delete/query.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/document/save_get_delete_document.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/aggregate_avg.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/aggregates_with_grouping.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/basic.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/basic_inference.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/compound.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/find_by_id.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/first_or_none.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/format.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/full_text_search_all_tables.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/full_text_table_search.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/in_partition.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/inner_query.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/list.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/not_inner_query.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/order_by.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/resolver.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/resolver_with_hints.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/search_by_resolver_fields.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/select_example.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/sorting_and_paging.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/query/update.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/save/basic.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/save/batch_save.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/save/cascade.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/save/cascade_builder.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/schema/basic.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/secrets/basic.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/seed.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/stream/close.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/stream/create_events.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/stream/delete_events.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/stream/query_stream.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/examples/stream/update_events.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/ai.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/config.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/entity_wire.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/errors.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/helpers/__init__.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/helpers/aggregates.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/helpers/sort.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/http.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/query_results.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/query_results_async.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/onyx_database/stream.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/plan/acceptance-criteria.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/plan/plan.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/scripts/bump-version.sh +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/scripts/release-flow.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/scripts/run-examples.sh +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tasks/01-http-resilience.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tasks/02-async-client.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tasks/03-query-values.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tasks/04-codegen-pydantic.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tasks/05-cli-parity.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tasks/06-packaging-ci.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tasks/07-onyx-cli-python-exports.md +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/fixtures/entity-wire-v1.json +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/fixtures/entity-wire-v1.msgpack.hex +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/test_ai.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/test_async.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/test_http.py +0 -0
- {onyx_database-2.2.0 → onyx_database-2.3.0}/tests/test_query_results.py +0 -0
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.0 - 2026-08-29
|
|
4
|
+
|
|
5
|
+
- Added typed, hard-bounded native `CANDIDATES`, `SEARCH_CANDIDATES`, and
|
|
6
|
+
`HNSW_CANDIDATES` query helpers to sync and async builders.
|
|
7
|
+
- Added lossless semantic-signature and HNSW wire validation, including signed
|
|
8
|
+
64-bit calibration identifiers, mixed-radix bucket checks, vector/work bounds,
|
|
9
|
+
and sole-root admission enforcement.
|
|
10
|
+
- Added the missing public `NOT_BETWEEN` operator/helper so the Python SDK now
|
|
11
|
+
covers every Cloud query operator.
|
|
12
|
+
|
|
3
13
|
## 2.2.0 - 2026-08-29
|
|
4
14
|
|
|
5
15
|
- Added sync and async `fenced_save`, `fenced_delete_where`, and `fenced_update_where` helpers for the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: onyx-database
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Python client SDK for Onyx Cloud Database (builder-pattern API and schema helpers)
|
|
5
5
|
Project-URL: Homepage, https://onyx.dev
|
|
6
6
|
Project-URL: Repository, https://github.com/OnyxDevTools/onyx-database-python
|
|
@@ -491,7 +491,7 @@ Importable helpers for conditions and sort:
|
|
|
491
491
|
from onyx_database import (
|
|
492
492
|
eq, neq, within, not_within,
|
|
493
493
|
in_op, not_in,
|
|
494
|
-
between,
|
|
494
|
+
between, not_between,
|
|
495
495
|
gt, gte, lt, lte,
|
|
496
496
|
like, not_like, contains, not_contains,
|
|
497
497
|
starts_with, not_starts_with, matches, not_matches,
|
|
@@ -503,6 +503,39 @@ from onyx_database import (
|
|
|
503
503
|
- Prefer `within` / `not_within` for inclusion checks (supports arrays, comma-separated strings, or inner queries).
|
|
504
504
|
- `in_op` / `not_in` remain available for backward compatibility and are exact aliases.
|
|
505
505
|
|
|
506
|
+
Native candidate channels are explicit and physically bounded:
|
|
507
|
+
|
|
508
|
+
```py
|
|
509
|
+
from onyx_database import hnsw_search_query
|
|
510
|
+
|
|
511
|
+
lexical = (
|
|
512
|
+
db.from_table("ActiveDocumentChunk")
|
|
513
|
+
.in_partition("revision-7")
|
|
514
|
+
.approximate_search("customer success", max_candidates=128)
|
|
515
|
+
.limit(20)
|
|
516
|
+
.list()
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
semantic = (
|
|
520
|
+
db.from_table("ChunkAttentionHash")
|
|
521
|
+
.in_partition("revision-7")
|
|
522
|
+
.hnsw_candidates(
|
|
523
|
+
hnsw_search_query(
|
|
524
|
+
calibration_id=73,
|
|
525
|
+
vector=prompt_embedding,
|
|
526
|
+
max_candidates=256,
|
|
527
|
+
ef_search=1024,
|
|
528
|
+
)
|
|
529
|
+
)
|
|
530
|
+
.limit(20)
|
|
531
|
+
.list()
|
|
532
|
+
)
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
`CANDIDATES`, `SEARCH_CANDIDATES`, and `HNSW_CANDIDATES` must be the sole root
|
|
536
|
+
criterion. Candidate results are approximate; exactly rerank them when the
|
|
537
|
+
full-precision vectors are available.
|
|
538
|
+
|
|
506
539
|
Aggregate / string helpers for `select()` expressions:
|
|
507
540
|
|
|
508
541
|
```py
|
|
@@ -554,7 +587,7 @@ roles_missing_permission = (
|
|
|
554
587
|
)
|
|
555
588
|
```
|
|
556
589
|
|
|
557
|
-
### Native
|
|
590
|
+
### Native vector-managed search
|
|
558
591
|
|
|
559
592
|
Use `.search(...)` on a builder or the `search` predicate helper to add a `MATCHES` condition against the `__full_text__` pseudo-field. `db.search(...)` sets `table = "ALL"` and seeds a query builder with that condition (extras like `partition`, `pageSize`, `nextPage` remain querystring params when provided).
|
|
560
593
|
|
|
@@ -694,6 +727,99 @@ Example request bodies emitted by the SDK:
|
|
|
694
727
|
}
|
|
695
728
|
```
|
|
696
729
|
|
|
730
|
+
For table-specific lexical, semantic, or hybrid search, build a validated
|
|
731
|
+
`VectorSearchQuery`. The helper accepts Python snake_case arguments and emits the
|
|
732
|
+
Cloud API's camelCase wire fields:
|
|
733
|
+
|
|
734
|
+
```py
|
|
735
|
+
from onyx_database import semantic_vector_signature, vector_search_query
|
|
736
|
+
|
|
737
|
+
signature = semantic_vector_signature(
|
|
738
|
+
calibration_id=-7909761245221418085,
|
|
739
|
+
bucket_id=5,
|
|
740
|
+
cells=[1, 2],
|
|
741
|
+
cell_counts=[2, 3],
|
|
742
|
+
fingerprint=["0x0123456789abcdef"],
|
|
743
|
+
boundary_confidence=0.2,
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
hybrid = vector_search_query(
|
|
747
|
+
text="storm warning",
|
|
748
|
+
semantic=signature,
|
|
749
|
+
min_score=0.15,
|
|
750
|
+
nearby_bucket_radius=2,
|
|
751
|
+
max_candidates=500,
|
|
752
|
+
require_all_terms=False,
|
|
753
|
+
)
|
|
754
|
+
|
|
755
|
+
db.from_table(tables.Document).search(hybrid).limit(20).list()
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
`VectorSearchQuery` requires text and/or a semantic signature. Its defaults are
|
|
759
|
+
`nearbyBucketRadius=1`, `maxCandidates=1000`, and `requireAllTerms=true`;
|
|
760
|
+
`maxCandidates` is bounded to `1..5000`. Semantic helpers validate the mixed-radix
|
|
761
|
+
bucket identifier, compute or verify exactly four fingerprint bands, keep the
|
|
762
|
+
non-zero signed 64-bit calibration identifier as decimal text, and emit fingerprint
|
|
763
|
+
words as fixed-width unsigned hexadecimal strings.
|
|
764
|
+
|
|
765
|
+
Three explicit candidate APIs provide physically bounded admission for downstream
|
|
766
|
+
reranking:
|
|
767
|
+
|
|
768
|
+
```py
|
|
769
|
+
from onyx_database import hnsw_search_query
|
|
770
|
+
|
|
771
|
+
# Bounded lexical admission from a SEARCHABLE table.
|
|
772
|
+
lexical = (
|
|
773
|
+
db.from_table(tables.Document)
|
|
774
|
+
.in_partition("corpus-a")
|
|
775
|
+
.approximate_search(
|
|
776
|
+
"storm warning",
|
|
777
|
+
min_score=0.1,
|
|
778
|
+
max_candidates=250,
|
|
779
|
+
require_all_terms=False,
|
|
780
|
+
)
|
|
781
|
+
.limit(20)
|
|
782
|
+
.list()
|
|
783
|
+
)
|
|
784
|
+
|
|
785
|
+
# Native HNSW nearest-neighbor admission.
|
|
786
|
+
hnsw = hnsw_search_query(
|
|
787
|
+
calibration_id=-7909761245221418085,
|
|
788
|
+
vector=[0.25, -0.5, 0.75],
|
|
789
|
+
max_candidates=100,
|
|
790
|
+
ef_search=400,
|
|
791
|
+
min_score=0.2,
|
|
792
|
+
)
|
|
793
|
+
neighbors = (
|
|
794
|
+
db.from_table(tables.Document)
|
|
795
|
+
.in_partition("corpus-a")
|
|
796
|
+
.hnsw_candidates(hnsw)
|
|
797
|
+
.list()
|
|
798
|
+
)
|
|
799
|
+
|
|
800
|
+
# Bounded EQUAL/IN-style admission from an ordinary secondary index.
|
|
801
|
+
routed = (
|
|
802
|
+
db.from_table(tables.Document)
|
|
803
|
+
.in_partition("corpus-a")
|
|
804
|
+
.approximate_candidates("tenantId", ["tenant-a", "tenant-b"], 200)
|
|
805
|
+
.list()
|
|
806
|
+
)
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
`SEARCH_CANDIDATES`, `HNSW_CANDIDATES`, and `CANDIDATES` are positive, read-only,
|
|
810
|
+
sole-root criteria. The builders reject attempts to combine them with `where`,
|
|
811
|
+
`and_`, `or_`, or `search` in either call order. Partitioned tables require one
|
|
812
|
+
concrete partition. HNSW vectors contain `1..16384` finite values with a non-zero
|
|
813
|
+
norm; `maxCandidates` is `1..5000`, `efSearch` is at least `maxCandidates` and at
|
|
814
|
+
most `20000`, and `minScore` is optional in `[-1, 1]`. The same methods and wire
|
|
815
|
+
validation are available on `AsyncQueryBuilder`.
|
|
816
|
+
|
|
817
|
+
Condition forms are exported as `approximate_search`, `hnsw_candidates`, and
|
|
818
|
+
`approximate_candidates`. Use them only as the sole condition, for example
|
|
819
|
+
`.where(approximate_search("storm", max_candidates=250))`. Database-wide
|
|
820
|
+
`db.search(...)` remains the text-only API because the `ALL` route performs its own
|
|
821
|
+
bounded lexical fan-out.
|
|
822
|
+
|
|
697
823
|
---
|
|
698
824
|
|
|
699
825
|
## Usage examples with `User`, `Role`, `Permission`
|
|
@@ -466,7 +466,7 @@ Importable helpers for conditions and sort:
|
|
|
466
466
|
from onyx_database import (
|
|
467
467
|
eq, neq, within, not_within,
|
|
468
468
|
in_op, not_in,
|
|
469
|
-
between,
|
|
469
|
+
between, not_between,
|
|
470
470
|
gt, gte, lt, lte,
|
|
471
471
|
like, not_like, contains, not_contains,
|
|
472
472
|
starts_with, not_starts_with, matches, not_matches,
|
|
@@ -478,6 +478,39 @@ from onyx_database import (
|
|
|
478
478
|
- Prefer `within` / `not_within` for inclusion checks (supports arrays, comma-separated strings, or inner queries).
|
|
479
479
|
- `in_op` / `not_in` remain available for backward compatibility and are exact aliases.
|
|
480
480
|
|
|
481
|
+
Native candidate channels are explicit and physically bounded:
|
|
482
|
+
|
|
483
|
+
```py
|
|
484
|
+
from onyx_database import hnsw_search_query
|
|
485
|
+
|
|
486
|
+
lexical = (
|
|
487
|
+
db.from_table("ActiveDocumentChunk")
|
|
488
|
+
.in_partition("revision-7")
|
|
489
|
+
.approximate_search("customer success", max_candidates=128)
|
|
490
|
+
.limit(20)
|
|
491
|
+
.list()
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
semantic = (
|
|
495
|
+
db.from_table("ChunkAttentionHash")
|
|
496
|
+
.in_partition("revision-7")
|
|
497
|
+
.hnsw_candidates(
|
|
498
|
+
hnsw_search_query(
|
|
499
|
+
calibration_id=73,
|
|
500
|
+
vector=prompt_embedding,
|
|
501
|
+
max_candidates=256,
|
|
502
|
+
ef_search=1024,
|
|
503
|
+
)
|
|
504
|
+
)
|
|
505
|
+
.limit(20)
|
|
506
|
+
.list()
|
|
507
|
+
)
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
`CANDIDATES`, `SEARCH_CANDIDATES`, and `HNSW_CANDIDATES` must be the sole root
|
|
511
|
+
criterion. Candidate results are approximate; exactly rerank them when the
|
|
512
|
+
full-precision vectors are available.
|
|
513
|
+
|
|
481
514
|
Aggregate / string helpers for `select()` expressions:
|
|
482
515
|
|
|
483
516
|
```py
|
|
@@ -529,7 +562,7 @@ roles_missing_permission = (
|
|
|
529
562
|
)
|
|
530
563
|
```
|
|
531
564
|
|
|
532
|
-
### Native
|
|
565
|
+
### Native vector-managed search
|
|
533
566
|
|
|
534
567
|
Use `.search(...)` on a builder or the `search` predicate helper to add a `MATCHES` condition against the `__full_text__` pseudo-field. `db.search(...)` sets `table = "ALL"` and seeds a query builder with that condition (extras like `partition`, `pageSize`, `nextPage` remain querystring params when provided).
|
|
535
568
|
|
|
@@ -669,6 +702,99 @@ Example request bodies emitted by the SDK:
|
|
|
669
702
|
}
|
|
670
703
|
```
|
|
671
704
|
|
|
705
|
+
For table-specific lexical, semantic, or hybrid search, build a validated
|
|
706
|
+
`VectorSearchQuery`. The helper accepts Python snake_case arguments and emits the
|
|
707
|
+
Cloud API's camelCase wire fields:
|
|
708
|
+
|
|
709
|
+
```py
|
|
710
|
+
from onyx_database import semantic_vector_signature, vector_search_query
|
|
711
|
+
|
|
712
|
+
signature = semantic_vector_signature(
|
|
713
|
+
calibration_id=-7909761245221418085,
|
|
714
|
+
bucket_id=5,
|
|
715
|
+
cells=[1, 2],
|
|
716
|
+
cell_counts=[2, 3],
|
|
717
|
+
fingerprint=["0x0123456789abcdef"],
|
|
718
|
+
boundary_confidence=0.2,
|
|
719
|
+
)
|
|
720
|
+
|
|
721
|
+
hybrid = vector_search_query(
|
|
722
|
+
text="storm warning",
|
|
723
|
+
semantic=signature,
|
|
724
|
+
min_score=0.15,
|
|
725
|
+
nearby_bucket_radius=2,
|
|
726
|
+
max_candidates=500,
|
|
727
|
+
require_all_terms=False,
|
|
728
|
+
)
|
|
729
|
+
|
|
730
|
+
db.from_table(tables.Document).search(hybrid).limit(20).list()
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
`VectorSearchQuery` requires text and/or a semantic signature. Its defaults are
|
|
734
|
+
`nearbyBucketRadius=1`, `maxCandidates=1000`, and `requireAllTerms=true`;
|
|
735
|
+
`maxCandidates` is bounded to `1..5000`. Semantic helpers validate the mixed-radix
|
|
736
|
+
bucket identifier, compute or verify exactly four fingerprint bands, keep the
|
|
737
|
+
non-zero signed 64-bit calibration identifier as decimal text, and emit fingerprint
|
|
738
|
+
words as fixed-width unsigned hexadecimal strings.
|
|
739
|
+
|
|
740
|
+
Three explicit candidate APIs provide physically bounded admission for downstream
|
|
741
|
+
reranking:
|
|
742
|
+
|
|
743
|
+
```py
|
|
744
|
+
from onyx_database import hnsw_search_query
|
|
745
|
+
|
|
746
|
+
# Bounded lexical admission from a SEARCHABLE table.
|
|
747
|
+
lexical = (
|
|
748
|
+
db.from_table(tables.Document)
|
|
749
|
+
.in_partition("corpus-a")
|
|
750
|
+
.approximate_search(
|
|
751
|
+
"storm warning",
|
|
752
|
+
min_score=0.1,
|
|
753
|
+
max_candidates=250,
|
|
754
|
+
require_all_terms=False,
|
|
755
|
+
)
|
|
756
|
+
.limit(20)
|
|
757
|
+
.list()
|
|
758
|
+
)
|
|
759
|
+
|
|
760
|
+
# Native HNSW nearest-neighbor admission.
|
|
761
|
+
hnsw = hnsw_search_query(
|
|
762
|
+
calibration_id=-7909761245221418085,
|
|
763
|
+
vector=[0.25, -0.5, 0.75],
|
|
764
|
+
max_candidates=100,
|
|
765
|
+
ef_search=400,
|
|
766
|
+
min_score=0.2,
|
|
767
|
+
)
|
|
768
|
+
neighbors = (
|
|
769
|
+
db.from_table(tables.Document)
|
|
770
|
+
.in_partition("corpus-a")
|
|
771
|
+
.hnsw_candidates(hnsw)
|
|
772
|
+
.list()
|
|
773
|
+
)
|
|
774
|
+
|
|
775
|
+
# Bounded EQUAL/IN-style admission from an ordinary secondary index.
|
|
776
|
+
routed = (
|
|
777
|
+
db.from_table(tables.Document)
|
|
778
|
+
.in_partition("corpus-a")
|
|
779
|
+
.approximate_candidates("tenantId", ["tenant-a", "tenant-b"], 200)
|
|
780
|
+
.list()
|
|
781
|
+
)
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
`SEARCH_CANDIDATES`, `HNSW_CANDIDATES`, and `CANDIDATES` are positive, read-only,
|
|
785
|
+
sole-root criteria. The builders reject attempts to combine them with `where`,
|
|
786
|
+
`and_`, `or_`, or `search` in either call order. Partitioned tables require one
|
|
787
|
+
concrete partition. HNSW vectors contain `1..16384` finite values with a non-zero
|
|
788
|
+
norm; `maxCandidates` is `1..5000`, `efSearch` is at least `maxCandidates` and at
|
|
789
|
+
most `20000`, and `minScore` is optional in `[-1, 1]`. The same methods and wire
|
|
790
|
+
validation are available on `AsyncQueryBuilder`.
|
|
791
|
+
|
|
792
|
+
Condition forms are exported as `approximate_search`, `hnsw_candidates`, and
|
|
793
|
+
`approximate_candidates`. Use them only as the sole condition, for example
|
|
794
|
+
`.where(approximate_search("storm", max_candidates=250))`. Database-wide
|
|
795
|
+
`db.search(...)` remains the text-only API because the `ALL` route performs its own
|
|
796
|
+
bounded lexical fan-out.
|
|
797
|
+
|
|
672
798
|
---
|
|
673
799
|
|
|
674
800
|
## Usage examples with `User`, `Role`, `Permission`
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""Public entrypoint for the Onyx Database Python SDK."""
|
|
2
|
+
|
|
3
|
+
from .config import WireFormat
|
|
4
|
+
from .errors import (
|
|
5
|
+
OnyxConfigError,
|
|
6
|
+
OnyxHTTPError,
|
|
7
|
+
OnyxUnauthorizedError,
|
|
8
|
+
OnyxNotFoundError,
|
|
9
|
+
OnyxRateLimitedError,
|
|
10
|
+
OnyxClientError,
|
|
11
|
+
OnyxServerError,
|
|
12
|
+
OnyxTimeoutError,
|
|
13
|
+
)
|
|
14
|
+
from .onyx import OnyxFacade, onyx
|
|
15
|
+
from .helpers.conditions import (
|
|
16
|
+
approximate_candidates,
|
|
17
|
+
approximate_search,
|
|
18
|
+
eq,
|
|
19
|
+
neq,
|
|
20
|
+
within,
|
|
21
|
+
not_within,
|
|
22
|
+
in_op,
|
|
23
|
+
not_in,
|
|
24
|
+
between,
|
|
25
|
+
not_between,
|
|
26
|
+
gt,
|
|
27
|
+
gte,
|
|
28
|
+
lt,
|
|
29
|
+
lte,
|
|
30
|
+
like,
|
|
31
|
+
not_like,
|
|
32
|
+
contains,
|
|
33
|
+
not_contains,
|
|
34
|
+
starts_with,
|
|
35
|
+
not_starts_with,
|
|
36
|
+
matches,
|
|
37
|
+
not_matches,
|
|
38
|
+
is_null,
|
|
39
|
+
not_null,
|
|
40
|
+
search,
|
|
41
|
+
hnsw_candidates,
|
|
42
|
+
)
|
|
43
|
+
from .helpers.candidate_search import (
|
|
44
|
+
DEFAULT_APPROXIMATE_INDEX_CANDIDATES,
|
|
45
|
+
DEFAULT_HNSW_CANDIDATES,
|
|
46
|
+
DEFAULT_HNSW_EF_SEARCH,
|
|
47
|
+
HNSW_QUERY_FORMAT_VERSION,
|
|
48
|
+
MAX_APPROXIMATE_INDEX_CANDIDATES,
|
|
49
|
+
MAX_APPROXIMATE_INDEX_ROUTE_VALUES,
|
|
50
|
+
MAX_HNSW_CANDIDATES,
|
|
51
|
+
MAX_HNSW_EF_SEARCH,
|
|
52
|
+
MAX_HNSW_VECTOR_DIMENSION,
|
|
53
|
+
MAX_VECTOR_SEARCH_CANDIDATES,
|
|
54
|
+
approximate_index_candidate_query,
|
|
55
|
+
hnsw_search_query,
|
|
56
|
+
semantic_vector_signature,
|
|
57
|
+
vector_search_query,
|
|
58
|
+
)
|
|
59
|
+
from .helpers.sort import asc, desc
|
|
60
|
+
from .onyx_async import OnyxAsyncFacade, onyx_async
|
|
61
|
+
from .types import (
|
|
62
|
+
ApproximateIndexCandidateQuery,
|
|
63
|
+
ApproximateSearchOptions,
|
|
64
|
+
FullTextQuery,
|
|
65
|
+
HnswSearchQuery,
|
|
66
|
+
HnswSearchQueryInput,
|
|
67
|
+
Int64WireInput,
|
|
68
|
+
QueryCriteriaOperator,
|
|
69
|
+
SemanticVectorSignature,
|
|
70
|
+
SemanticVectorSignatureInput,
|
|
71
|
+
VectorSearchQuery,
|
|
72
|
+
VectorSearchQueryInput,
|
|
73
|
+
)
|
|
74
|
+
from .helpers.aggregates import (
|
|
75
|
+
avg,
|
|
76
|
+
sum,
|
|
77
|
+
count,
|
|
78
|
+
min,
|
|
79
|
+
max,
|
|
80
|
+
std,
|
|
81
|
+
variance,
|
|
82
|
+
median,
|
|
83
|
+
upper,
|
|
84
|
+
lower,
|
|
85
|
+
substring,
|
|
86
|
+
replace,
|
|
87
|
+
format,
|
|
88
|
+
percentile,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
__all__ = [
|
|
92
|
+
"OnyxFacade",
|
|
93
|
+
"OnyxAsyncFacade",
|
|
94
|
+
"onyx",
|
|
95
|
+
"onyx_async",
|
|
96
|
+
"WireFormat",
|
|
97
|
+
"OnyxConfigError",
|
|
98
|
+
"OnyxHTTPError",
|
|
99
|
+
"OnyxUnauthorizedError",
|
|
100
|
+
"OnyxNotFoundError",
|
|
101
|
+
"OnyxRateLimitedError",
|
|
102
|
+
"OnyxClientError",
|
|
103
|
+
"OnyxServerError",
|
|
104
|
+
"OnyxTimeoutError",
|
|
105
|
+
# conditions
|
|
106
|
+
"eq",
|
|
107
|
+
"neq",
|
|
108
|
+
"within",
|
|
109
|
+
"not_within",
|
|
110
|
+
"in_op",
|
|
111
|
+
"not_in",
|
|
112
|
+
"between",
|
|
113
|
+
"not_between",
|
|
114
|
+
"gt",
|
|
115
|
+
"gte",
|
|
116
|
+
"lt",
|
|
117
|
+
"lte",
|
|
118
|
+
"like",
|
|
119
|
+
"not_like",
|
|
120
|
+
"contains",
|
|
121
|
+
"not_contains",
|
|
122
|
+
"starts_with",
|
|
123
|
+
"not_starts_with",
|
|
124
|
+
"matches",
|
|
125
|
+
"not_matches",
|
|
126
|
+
"is_null",
|
|
127
|
+
"not_null",
|
|
128
|
+
"search",
|
|
129
|
+
"approximate_search",
|
|
130
|
+
"hnsw_candidates",
|
|
131
|
+
"approximate_candidates",
|
|
132
|
+
# native candidate-search wire helpers
|
|
133
|
+
"HNSW_QUERY_FORMAT_VERSION",
|
|
134
|
+
"DEFAULT_HNSW_CANDIDATES",
|
|
135
|
+
"DEFAULT_HNSW_EF_SEARCH",
|
|
136
|
+
"MAX_HNSW_CANDIDATES",
|
|
137
|
+
"MAX_HNSW_EF_SEARCH",
|
|
138
|
+
"MAX_HNSW_VECTOR_DIMENSION",
|
|
139
|
+
"DEFAULT_APPROXIMATE_INDEX_CANDIDATES",
|
|
140
|
+
"MAX_APPROXIMATE_INDEX_CANDIDATES",
|
|
141
|
+
"MAX_APPROXIMATE_INDEX_ROUTE_VALUES",
|
|
142
|
+
"MAX_VECTOR_SEARCH_CANDIDATES",
|
|
143
|
+
"semantic_vector_signature",
|
|
144
|
+
"vector_search_query",
|
|
145
|
+
"hnsw_search_query",
|
|
146
|
+
"approximate_index_candidate_query",
|
|
147
|
+
# public search types
|
|
148
|
+
"ApproximateIndexCandidateQuery",
|
|
149
|
+
"ApproximateSearchOptions",
|
|
150
|
+
"FullTextQuery",
|
|
151
|
+
"HnswSearchQuery",
|
|
152
|
+
"HnswSearchQueryInput",
|
|
153
|
+
"Int64WireInput",
|
|
154
|
+
"QueryCriteriaOperator",
|
|
155
|
+
"SemanticVectorSignature",
|
|
156
|
+
"SemanticVectorSignatureInput",
|
|
157
|
+
"VectorSearchQuery",
|
|
158
|
+
"VectorSearchQueryInput",
|
|
159
|
+
# sort
|
|
160
|
+
"asc",
|
|
161
|
+
"desc",
|
|
162
|
+
# aggregates
|
|
163
|
+
"avg",
|
|
164
|
+
"sum",
|
|
165
|
+
"count",
|
|
166
|
+
"min",
|
|
167
|
+
"max",
|
|
168
|
+
"std",
|
|
169
|
+
"variance",
|
|
170
|
+
"median",
|
|
171
|
+
"upper",
|
|
172
|
+
"lower",
|
|
173
|
+
"substring",
|
|
174
|
+
"replace",
|
|
175
|
+
"format",
|
|
176
|
+
"percentile",
|
|
177
|
+
]
|