find longest string (longest tweet)? mongodb. -
i have database of tweets actual tweet text in field called "text".
it looks this:
"_id" : objectid("519184ad34dfb73dcdfdda2f"), "created_at" : "mon may 13 01:41:25 +0000 2013", "id" : numberlong("333758850945667072"), "id_str" : "333758850945667072", "text" : "no quiero ir la. escuela",
i wondering how query , show longest tweet? i've thinking maybe .sort or .length or i've looked around , haven't found that's worked far.
help! thanks!
if need perform longest-tweet extraction best approach keeping length of tweet separate field in document , having index on it. can fast queries .sort(-1).limit(1). can write own script importing json data mongodb (http://docs.mongodb.org/ecosystem/drivers/) , add length field on import.
any alternative approach imply full collection scan in order find document maximum value of 'text.length'. resource-demanding operation , shall avoided unless effectiveness not concern.
Comments
Post a Comment