Store documents with metadata in Qdrant and filter by department
Qdrant stores each vector together with a JSON payload and can filter searches on that payload. This tutorial uses the Python client to save chunks with department and access group and to restrict a search to one department.

What you will build and what you need first
At the end you will have a small Qdrant collection in which every point carries a department, an access group and the chunk text. You will also run a search that returns only points of one department. Enterprise search that respects permissions rests on this building block.
You need Docker, Python and the Python client from the Qdrant README. The vectors in this example have four dimensions and are written by hand. In a real system an embedding model produces them, and the README does not cover that step.
The README describes Qdrant as a vector similarity search engine and vector database. It is tailored for extended filtering support, which is the reason it suits permission-aware search. The tutorial keeps to a single collection and two points so that you can see each effect of the filter directly.
Start the server and connect
The README starts a local server with one container command. It maps port 6333 and runs the image qdrant/qdrant.
docker run -p 6333:6333 qdrant/qdrantThe README warns that this deployment has no authentication and listens on all network interfaces. Use it only for testing, and read the security guide before anything goes to production. The next block connects the Python client to the running server.
from qdrant_client import QdrantClient
client = QdrantClient(url="http://localhost:6333")Store chunks with a payload
Qdrant calls a vector with an additional payload a point. The payload accepts any JSON, so department, access group and the chunk text can sit next to the vector. The following block creates a collection named docs with cosine distance and four dimensions, then writes two points for different departments.
from qdrant_client.models import Distance, VectorParams, PointStruct
client.create_collection(
collection_name="docs",
vectors_config=VectorParams(size=4, distance=Distance.COSINE),
)
client.upsert(
collection_name="docs",
points=[
PointStruct(id=1, vector=[0.1, 0.2, 0.3, 0.4],
payload={"department": "hr", "access_group": "hr-team",
"text": "Urlaubsregelung"}),
PointStruct(id=2, vector=[0.2, 0.1, 0.4, 0.3],
payload={"department": "finance", "access_group": "finance-team",
"text": "Reisekosten"}),
],
)Each point has an id and a vector, and the payload holds everything you later want to filter on. Because the payload is plain JSON, you can add further fields such as a document name or a page number without changing the collection definition. Decide early which fields you need for permissions, since every chunk must carry them.
Filter the search by department or group
The README describes filtering on payload with the clauses should, must and must_not, combined with conditions such as keyword matching. The block below sends a query vector and requires that the department equals hr. Replace the key with access_group to filter by group instead.
from qdrant_client.models import Filter, FieldCondition, MatchValue
hits = client.query_points(
collection_name="docs",
query=[0.1, 0.2, 0.3, 0.4],
query_filter=Filter(must=[
FieldCondition(key="department", match=MatchValue(value="hr"))
]),
limit=3,
)
for p in hits.points:
print(p.id, p.payload["text"])The must clause means every listed condition has to hold for a point to qualify. The should clause works as an alternative, so a point qualifies when at least one condition holds, which helps when a user belongs to several groups. The must_not clause excludes points, for example those of a department the user may not see.
Check the result and avoid common mistakes
The script should print only point 1 with the text Urlaubsregelung. If you change the value to finance, point 2 should appear instead. Without the filter both points are candidates, so a changed result confirms that the filter is applied.
The README names a few points that matter here. The test container has no authentication, so anyone who reaches port 6333 can read every payload. The README also lists payload indexes, which Qdrant uses for query planning, but it does not show how to create them, so check the documentation before loading large collections. The filter also works only on what you stored, which means every chunk needs its department and group written at upload time.
Where this fits in a company
A payload filter is one layer of a permission model. The application must still look up the groups of the signed-in user and pass them into the filter on every query. Someone in IT has to own that mapping, keep the payload fields in step with changes in the source systems and secure the server. Companies commonly ask their data protection officer and the works council (Betriebsrat) to review such a setup when it indexes personnel or finance documents.
souveraen.ai connects sources such as SharePoint and file servers read-only and with the existing permissions. It runs either hosted in Germany or on-premise. If you would rather not build this yourself, see knowledge management software, the security overview and the on-premise option. Background on running models in your own network is on the local AI page.
Sources
- Qdrant README, Qdrant


