Skip to main content
Applies to:


Summary

Issue: Filtering logs with chained OR operations like metadata.user_id MATCH 'id1' OR metadata.user_id MATCH 'id2' fails when exceeding 128 conditions due to a backend JSON nesting recursion limit. Cause: Chained OR queries are nested in JSON on the backend and hit the 128 query recursion limit. Resolution: Use the IN operator instead of chained OR operations to filter by large sets of user IDs.

Resolution Steps

Use the IN operator for large ID sets

Step 1: Replace chained OR queries with IN operator

Use square brackets and the IN operator syntax for filtering metadata fields.
metadata.user_id in ['50157c3d-edd9-4287-85ee-48c119967099', 'a3fe059a-e4f4-4e9f-b3e3-0da04ed1f075', '913b6ae1-72aa-4113-964e-e41364933a43']

Step 2: Verify query performance

The IN operator supports 300+ IDs and avoids the recursion limit entirely.

Alternative: Use the API for programmatic filtering

Step 1: Query logs via Braintrust API

Use the Braintrust API to fetch and filter logs programmatically if the IN operator doesn’t meet your requirements.