Skip to content

Commit

Permalink
feat: Added multi-category filtering and bumping latest version ot 0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tazarov committed Jul 15, 2024
1 parent db1b987 commit d260825
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

This is a collection of small guides and recipes to help you get started with ChromaDB.

Latest ChromaDB version: [0.5.3](https://github.com/chroma-core/chroma/releases/tag/0.5.3)
Latest ChromaDB version: [0.5.4](https://github.com/chroma-core/chroma/releases/tag/0.5.4)

**Latest Releases highlights:**

- Adds async client support

## New and Noteworthy

-[Multi-Category Filtering](strategies/multi-category-filters.md) - Learn how to filter data based on multiple categories - 📅`15-Jul-2024`
- 🔒 [Chroma Auth](security/auth.md) - Learn how to secure your Chroma deployment with Authentication - 📅`11-Jul-2024`
- 📦 [Async Http Client](core/clients.md#http-client) - Chroma now supports async HTTP clients - 📅`19-Jun-2024`
- 🔒 [Security](security/index.md) - Learn how to secure your Chroma deployment - 📅`13-Jun-2024`
- 🔧 [Installation](core/install.md) - Learn about the different ways to install Chroma - 📅`08-Jun-2024`
- 🧠 [Memory Management](strategies/memory-management.md) - Learn how to manage memory in ChromaDB - 📅`30-May-2024`
- 📐 [Resource Requirements](core/resources.md) - Recently updated with temporary storage requirements - 📅`28-May-2024`
- ⁉️[FAQs](faq/index.md) - Facing an issue, check out our FAQ section for answers. - 📅`28-May-2024`
- 💾 [Chroma Storage Layout](core/storage-layout.md) - Understand how Chroma stores persistent data - 📅`21-May-2024`

## Getting Started

Expand Down
27 changes: 27 additions & 0 deletions docs/strategies/multi-category-filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Multi-Category Filters

Sometimes you may want to filter documents in Chroma based on multiple categories e.g. `games` and `movies`.
Unfortunately, Chroma does not yet support complex data-types like lists or sets so that one can use a single metadata
field to store and filter by. It is also not possible to use fuzzy search `LIKE` queries on metadata fields.

To solve this problem without introducing a complex logic on the client side, we suggest the following approach.

When adding document to a collection add each category it belongs to as a boolean metadata field:

!!! note "No Empty Categories"

Only add categories an item belongs to with flags set to `True`.
Do not add categories an item does not belong to and set the flag to `False`.

```python
import uuid

collection.add(ids=[f"{uuid.uuid4()}"], documents=["This is a document"], metadatas=[{"games": True, "movies": True}])
```

When querying documents, you can filter by multiple categories by using the `where` parameter:

```python
results = collection.query(query_texts=["This is a query document"], where={"games": True, "movies": True})
```

0 comments on commit d260825

Please sign in to comment.