Skip to content

Commit

Permalink
Add more Qdrant examples (docarray#1527)
Browse files Browse the repository at this point in the history
Signed-off-by: Kacper Łukawski <lukawski.kacper@gmail.com>
  • Loading branch information
kacperlukawski authored May 10, 2023
1 parent bfebad6 commit 9705431
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/user_guide/storing/index_qdrant.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ class MyDocument(BaseDoc):
qdrant_config = QdrantDocumentIndex.DBConfig(":memory:")
doc_index = QdrantDocumentIndex[MyDocument](qdrant_config)

# Connecting to a local Qdrant instance running as a Docker container
qdrant_config = QdrantDocumentIndex.DBConfig("http://localhost:6333")
doc_index = QdrantDocumentIndex[MyDocument](qdrant_config)

# Connecting to Qdrant Cloud service
qdrant_config = QdrantDocumentIndex.DBConfig(
"https://YOUR-CLUSTER-URL.aws.cloud.qdrant.io",
api_key="<your-api-key>",
)
doc_index = QdrantDocumentIndex[MyDocument](qdrant_config)

# Indexing the documents
doc_index.index(
[
Expand Down Expand Up @@ -115,4 +126,22 @@ results = doc_index.filter(
],
),
)

# Vector search with additional filtering. Qdrant has the additional filters
# incorporated directly into the vector search phase, without a need to perform
# pre or post-filtering.
query = (
index.build_query()
.find(np.random.random(512), search_field="image_embedding")
.filter(filter_query=models.Filter(
must=[
models.FieldCondition(
key="title",
match=models.MatchText(text="document 2"),
),
],
))
.build(limit=5)
)
results = index.execute_query(query)
```

0 comments on commit 9705431

Please sign in to comment.