Learn how to filter workspaces, peers, sessions, and messages using Honcho’s powerful filtering system
Honcho provides a sophisticated filtering system that allows you to query workspaces, peers, sessions, and messages with precise control. The filtering system supports logical operators, comparison operators, metadata filtering, and wildcards to help you find exactly what you need.
Filters in Honcho are expressed as dictionaries that define conditions for matching resources. The system supports both simple equality filters and complex queries with multiple conditions.
Create sophisticated queries by combining different logical operators:
Copy
# Find messages from alice OR bob, but NOT where message has archived set to true in metadatamessages = session.get_messages(filters={ "AND": [ { "OR": [ {"peer_id": "alice"}, {"peer_id": "bob"} ] }, { "NOT": [ {"metadata": {"archived": True}} ] } ]})
If you want to do advanced queries like these, make sure not to create metadata fields that use the same names as the included comparison operators! For example, if you have a metadata field called contains, it will conflict with the contains operator.
# Find all sessions with any peer_id (essentially all sessions)sessions = honcho.get_sessions(filters={ "peer_id": "*"})# Wildcard in lists - matches everythingmessages = session.get_messages(filters={ "peer_id": {"in": ["alice", "bob", "*"]}})# Metadata wildcardssessions = honcho.get_sessions(filters={ "metadata": { "type": "*", # Any type "status": "active" # But status must be active }})
Honcho’s filtering system provides powerful capabilities for querying your conversational data. By understanding how to:
Use simple equality filters and complex logical operators
Apply comparison operators for range and pattern matching
Filter metadata with nested conditions
Handle wildcards and dynamic filter construction
Follow best practices for performance and validation
You can build sophisticated applications that efficiently find and process exactly the conversations, messages, and insights you need from your Honcho data.