How to select documents larger than x bytes?

Hi,

Is there a way to list documents that are large/smaller than x bytes?

Thanks,
Moon

Hey @moon0326,

I know this isn’t exactly bytes like you were initially looking for, but would something like this work?:

http://blog.couchbase.com/calculating-average-document-size-documents-stored-couchbase

You can create a view that does JSON.stringify on every document, get the length, and then do some logic to emit results based on the string length. Of course each character in a string could have a different byte size depending on the character encoding, but maybe this will accomplish enough of what you need?

Let me know if this helps at all.

Best,

1 Like

@nraboy Thank you! Yes, I think that trick should work :slight_smile:

Awesome!

Reach out if you need anything else :slight_smile: