How to select documents larger than x bytes?


#1

Hi,

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

Thanks,
Moon


#2

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,


#3

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


#4

Awesome!

Reach out if you need anything else :slight_smile: