# URGENT: Filtering Retrieval Search in Weaviate Based on Tenant-Specific Uploaded Files

**URL:** <https://forum.weaviate.io/t/urgent-filtering-retrieval-search-in-weaviate-based-on-tenant-specific-uploaded-files/1232>\
**Category:** Support\
**Created:** [January 16, 2024, 5:35am UTC](https://forum.weaviate.io/t/urgent-filtering-retrieval-search-in-weaviate-based-on-tenant-specific-uploaded-files/1232 "2024-01-16T05:35:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmanAda](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@AmanAda](https://forum.weaviate.io/u/AmanAda)\
**Post date:** [January 16, 2024, 5:35am UTC](https://forum.weaviate.io/t/urgent-filtering-retrieval-search-in-weaviate-based-on-tenant-specific-uploaded-files/1232/1 "2024-01-16T05:35:29Z")

</div>

I am currently working on a critical project that involves implementing a multi-tenant system using Weaviate for RAG, and I’m faced with a challenge related to filtering retrieval searches based on certain uploaded files for each tenant.

Specifically, I would like to understand how I can configure Weaviate to allow retrieval searches that are filtered to specific files uploaded by a tenant. Are there specific query parameters or configurations that I need to consider to work with langchain?

For example, a tenant has 10 files and I want to search only 5 of them, how can I do it?

Any guidance or examples on how to achieve this would be greatly appreciated. I want to ensure that the retrieval search results are scoped to the relevant files associated with the selected tenant in the system.

---

<div class="post-metadata">

**Author:** ![sebawita](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/sebawita/32/5_2.png) [@sebawita](https://forum.weaviate.io/u/sebawita)\
**Post date:** [January 16, 2024, 11:45am UTC](https://forum.weaviate.io/t/urgent-filtering-retrieval-search-in-weaviate-based-on-tenant-specific-uploaded-files/1232/2 "2024-01-16T11:45:35Z")

</div>

Hi @AmanAda,  
I am not an expert in langchain, but I can speak from a Weaviate level.

Overall, you don’t need to configure Weaviate in any special way. You only need a property with a `file_name` (or some other identificator), and you can filter using `contains_any`.

## Get the tenant

First, as part of your query, you need to specify the tenant you are searching on. With the Python client, this looks like this:

```python
my_collection = client.collections.get("MyCollectionName")

# Get the specific tenant's version of the collection
my_tenant = my_collection.with_tenant("tenant_name")

```

See more [here](https://weaviate.io/developers/weaviate/search/basics#multi-tenancy).

## Filter (contains\_any) on files

Then, you need to run a query on the tenant with a filter using `contains_any`, which should contain all the files you want to search on. Here is an example with a Weaviate Python client:

```auto
import weaviate.classes as wvc

response = my_tenant.query.near_text(
    query="search term here",
    filters=wvc.Filter("file_name").contains_any(["file1", "file2", "file3"]),
    limit=4
)

```
