turbopuffer / turbopuffer-typescript

Official Typescript API client library for turbopuffer.com
MIT License
8 stars 1 forks source link

Determining unset or empty []string attribute #31

Open egoldschmidt opened 4 hours ago

egoldschmidt commented 4 hours ago

We are adding a new attribute that contains a filterable array of strings, but we want backwards compatibility with old data that does not have this set yet. So my thinking was to leverage a filter of the form [x, 'Eq', null] or [x, 'Eq' []]. Alas neither seems to work:

filter error in keyx: type mismatch, Eq expects array filter operator, but got null

or

filter error in keyx: type mismatch, Eq expects array filter operator, but got []

Please let me know if there is a better way to approach this, thanks!

pushrax commented 2 hours ago

Can you clarify the use case? I'm not following how "we want backwards compatibility with old data" would lead to querying for null or [].

The error message you're seeing seems like it needs to be improved, it should read something like Eq cannot be used on an array attribute

egoldschmidt commented 21 minutes ago

I was intending to have a query filter that looked for records with the attribute set OR the attribute entirely unset (implying it was legacy data, which would be backfilled over time, and for which it was OK to preserve existing behavior)

E.g., ['Or', [['attribute', 'Eq', null], ['attribute', 'In', ['value1', 'value2']]]]

But my use case aside: is there any way to check for an unset or empty array?