Skip to content

Enhanced Metadata Filtering Not Working when using Weaviate as Vector DB #4053

@takaakimatsuo

Description

@takaakimatsuo

🐛 Describe the bug

Summary

I am just testing around with self-hosted Mem0, with various vector DBs.
I would love to try filtering but having a hard time making it work.
The Qdrant did not work for the same reason descried in another issue.

When using Weaviate, it throws no error but any filter seems to be ignored or not working.

Official mem0 doc says:

Full operator coverage with advanced text filters. Best option when you need hybrid text + metadata queries.

Environment

  • mem0 version: 1.0.3
  • weaviate-client version: 4.19.2
  • weaviate server version: semitechnologies/weaviate: latest (Docker image), 1.36.0-rc.0
  • Python version: 3.12.11
  • OS: MacOs 15.5

Weaviate docker compose

   weaviate:
        image: semitechnologies/weaviate:latest
        ports:
          - "8080:8080"
          - "50051:50051"
        environment:
          QUERY_DEFAULTS_LIMIT: 25
          AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: "true"
          PERSISTENCE_DATA_PATH: "/var/lib/weaviate"
          DEFAULT_VECTORIZER_MODULE: "none"
          ENABLE_MODULES: ""

Sample python code

Config

from mem0 import Memory

config = {
    "vector_store": {
        "provider": "weaviate",
        "config": {
            "collection_name": "test",
            "cluster_url": "http://localhost:8080",
            "auth_client_secret": None,
        }
    }
}

m = Memory.from_config(config)

By the way it spits out

DeprecationWarning: Dep024: You are using the vectorizer_config argument in collection.config.create(), which is deprecated. Use the vector_config argument instead.

Memory Add

messages = [
    {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
    {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."},
    {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
    {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
]
m.add(messages, user_id="alice", metadata={"category": "movies", "test": 0})

Seems properly saving something.

{'results': [{'id': '1fb2ee17-57f0-4f95-8c81-df2a645b9bec',
   'memory': 'Loves sci-fi movies',
   'event': 'ADD'},
  {'id': '2b920e65-18a0-4abd-b9a6-4f9c2de8302a',
   'memory': 'Not a big fan of thriller movies',
   'event': 'ADD'}]}

Searching

Not-Working patterns

import json
results = m.search(
    "recommend content",
    user_id="alice",
    filters={"category": "test"}
)
print(json.dumps(results, indent=2))
print(f"Search records: {len(results["results"])}")

Since filters specifies category as "test", I expected no results to be returned but got:

{
  "results": [
    {
      "id": "1fb2ee17-57f0-4f95-8c81-df2a645b9bec",
      "memory": "Loves sci-fi movies",
      "hash": "1110b1af77367917ea2022355a16f187",
      "metadata": {
        "category": "movies"
      },
      "score": 0.699999988079071,
      "created_at": "2026-02-15T01:59:48.810746-08:00",
      "updated_at": null,
      "user_id": "alice"
    },
    {
      "id": "2b920e65-18a0-4abd-b9a6-4f9c2de8302a",
      "memory": "Not a big fan of thriller movies",
      "hash": "028dfab4483f28980e292f62578d3293",
      "metadata": {
        "category": "movies"
      },
      "score": 0.0,
      "created_at": "2026-02-15T01:59:49.856939-08:00",
      "updated_at": null,
      "user_id": "alice"
    }
  ]
}
Search records: 2

Any other filters seems not working at all.

Working patterns

Pattern 1

import json
results = m.search(
    "recommend content",
    user_id="alice",
)
print(json.dumps(results, indent=2))
print(f"Search records: {len(results["results"])}")

Output is:

import json
results = m.search(
    "recommend content",
    user_id="alice",
)
print(json.dumps(results, indent=2))
print(f"Search records: {len(results["results"])}")

Pattern 2

import json
results = m.search(
    "recommend content",
    user_id="bob",
)
print(json.dumps(results, indent=2))
print(f"Search records: {len(results["results"])}")

Output is:

{
  "results": []
}
Search records: 0

Pattern 3

import json
results = m.search(
    "recommend content",
    user_id="alice",
    filters={"category": "movies"}
)
print(json.dumps(results, indent=2))
print(f"Search records: {len(results["results"])}")

Output is:
(This looks like it is working, but I suppose the filter is simply ignored.)

{
  "results": [
    {
      "id": "1fb2ee17-57f0-4f95-8c81-df2a645b9bec",
      "memory": "Loves sci-fi movies",
      "hash": "1110b1af77367917ea2022355a16f187",
      "metadata": {
        "category": "movies"
      },
      "score": 0.699999988079071,
      "created_at": "2026-02-15T01:59:48.810746-08:00",
      "updated_at": null,
      "user_id": "alice"
    },
    {
      "id": "2b920e65-18a0-4abd-b9a6-4f9c2de8302a",
      "memory": "Not a big fan of thriller movies",
      "hash": "028dfab4483f28980e292f62578d3293",
      "metadata": {
        "category": "movies"
      },
      "score": 0.0,
      "created_at": "2026-02-15T01:59:49.856939-08:00",
      "updated_at": null,
      "user_id": "alice"
    }
  ]
}
Search records: 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumAnnoying but has workaroundsbugSomething isn't workingvector-storeVector store backends (Qdrant, PGVector, Redis, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions