mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-03 01:48:32 +02:00
* docs(edge): add "Modify the Vector Schema" step to quickstart Documents the new Edge 0.7 API for adding and removing named vector fields on an existing shard without recreating it, with Python and Rust snippets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(edge): mention quantization support in quickstart Adds a note after the EdgeConfig snippet that Edge supports all four quantization methods (Scalar, Product, Binary, TurboQuant), with a link to the quantization guide. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(edge): add On-Device BM25 page for Edge 0.7 New guide covering the built-in BM25 sparse embedder: configuring a sparse vector shard, creating a Bm25/EdgeBm25 embedder, embedding and upserting documents, and querying. Includes Python and Rust snippets. Also adds the page to the Edge index navigation table. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(edge): add WAL segment size configuration to quickstart Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Upgrade code snippets to Edge 0.7.2 * Review feedback --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
139 lines
3.1 KiB
Python
139 lines
3.1 KiB
Python
# @block-start create-storage-directory
|
|
from pathlib import Path
|
|
|
|
SHARD_DIRECTORY = "./qdrant-edge-directory"
|
|
|
|
Path(SHARD_DIRECTORY).mkdir(parents=True, exist_ok=True)
|
|
# @block-end create-storage-directory
|
|
|
|
# @block-start configure-edge-shard
|
|
from qdrant_edge import (
|
|
Distance,
|
|
EdgeConfig,
|
|
EdgeVectorParams,
|
|
)
|
|
|
|
VECTOR_NAME="my-vector"
|
|
VECTOR_DIMENSION=4
|
|
|
|
config = EdgeConfig(
|
|
vectors={
|
|
VECTOR_NAME: EdgeVectorParams(
|
|
size=VECTOR_DIMENSION,
|
|
distance=Distance.Cosine,
|
|
)
|
|
}
|
|
)
|
|
# @block-end configure-edge-shard
|
|
|
|
# @block-start initialize-edge-shard
|
|
from qdrant_edge import EdgeShard
|
|
|
|
edge_shard = EdgeShard.create(SHARD_DIRECTORY, config)
|
|
# @block-end initialize-edge-shard
|
|
|
|
# @block-start upsert-points
|
|
from qdrant_edge import ( Point, UpdateOperation )
|
|
|
|
point = Point(
|
|
id=1,
|
|
vector={VECTOR_NAME: [0.1, 0.2, 0.3, 0.4]},
|
|
payload={"color": "red"}
|
|
)
|
|
|
|
edge_shard.update(UpdateOperation.upsert_points([point]))
|
|
# @block-end upsert-points
|
|
|
|
# @block-start retrieve-point
|
|
records = edge_shard.retrieve(
|
|
point_ids=[1],
|
|
with_payload=True,
|
|
with_vector=False
|
|
)
|
|
# @block-end retrieve-point
|
|
|
|
# @block-start modify-vector-schema
|
|
from qdrant_edge import Modifier
|
|
|
|
edge_shard.update(UpdateOperation.create_sparse_vector(
|
|
vector_name="text",
|
|
modifier=Modifier.Idf,
|
|
))
|
|
# @block-end modify-vector-schema
|
|
|
|
# @block-start query-points
|
|
from qdrant_edge import Query, QueryRequest
|
|
|
|
results = edge_shard.query(
|
|
QueryRequest(
|
|
query=Query.Nearest([0.2, 0.1, 0.9, 0.7], using=VECTOR_NAME),
|
|
limit=10,
|
|
with_vector=False,
|
|
with_payload=True
|
|
)
|
|
)
|
|
# @block-end query-points
|
|
|
|
# @block-start filter
|
|
from qdrant_edge import FieldCondition, Filter, MatchValue
|
|
|
|
results = edge_shard.query(
|
|
QueryRequest(
|
|
query=Query.Nearest([0.2, 0.1, 0.9, 0.7], using=VECTOR_NAME),
|
|
filter=Filter(
|
|
must=[
|
|
FieldCondition(
|
|
key="color",
|
|
match=MatchValue(value="red"),
|
|
)
|
|
]
|
|
),
|
|
limit=10,
|
|
with_vector=False,
|
|
with_payload=True
|
|
)
|
|
)
|
|
# @block-end filter
|
|
|
|
# @block-start facet
|
|
from qdrant_edge import FacetRequest
|
|
|
|
facet_response = edge_shard.facet(FacetRequest(key="color", limit=10, exact=False))
|
|
# @block-end facet
|
|
|
|
# @block-start optimize
|
|
edge_shard.optimize()
|
|
# @block-end optimize
|
|
|
|
# @block-start configure-optimizer
|
|
from qdrant_edge import EdgeOptimizersConfig
|
|
|
|
config = EdgeConfig(
|
|
vectors={
|
|
VECTOR_NAME: EdgeVectorParams(
|
|
size=VECTOR_DIMENSION,
|
|
distance=Distance.Cosine,
|
|
)
|
|
},
|
|
optimizers=EdgeOptimizersConfig(
|
|
deleted_threshold=0.2,
|
|
vacuum_min_vector_number=100,
|
|
default_segment_number=2,
|
|
),
|
|
)
|
|
# @block-end configure-optimizer
|
|
|
|
# @block-start create-payload-index
|
|
from qdrant_edge import PayloadSchemaType
|
|
|
|
edge_shard.update(UpdateOperation.create_field_index("color", PayloadSchemaType.Keyword))
|
|
# @block-end create-payload-index
|
|
|
|
# @block-start close-edge-shard
|
|
edge_shard.close()
|
|
# @block-end close-edge-shard
|
|
|
|
# @block-start load-edge-shard
|
|
edge_shard = EdgeShard.load(SHARD_DIRECTORY)
|
|
# @block-end load-edge-shard
|