incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Go Hori ...@livemocha.com>
Subject Re: Resend: Emulating S3 path convention
Date Fri, 14 Oct 2011 14:38:01 GMT
I was missing a key= parameter, and that was why I was getting ALL the
results.

Thank you for your help.
Go

On Wed, Oct 12, 2011 at 11:15 PM, CGS <cgsmcmlxxv@gmail.com> wrote:
> Hi,
>
> If I understood correctly your problem, I think you will find your answer
> here:
>
> http://guide.couchdb.org/editions/1/en/views.html
>
> Cheers,
> CGS
>
>
>
> On 10/12/2011 04:56 PM, Go Hori wrote:
>>
>> Hello,
>>
>> I am resending this hoping someone has some insight...
>> Please let me know if I can clarify my question in any way.
>>
>> Thank you in advance,
>> Go
>>
>>
>> ---------- Forwarded message ----------
>> From: Go Hori<go@livemocha.com>
>> Date: Tue, Oct 11, 2011 at 8:45 AM
>> Subject: Emulating S3 path convention
>> To: user@couchdb.apache.org
>>
>>
>> Hi,
>>
>> I see a few references to implementing S3 like naming convention in
>> which an id contains a delimiter and an application can emulate
>> directory lookup using 'prefix' and 'delimiter' search parameters.
>> Has anyone done something like this with couch?
>>
>>
>> http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?ListingKeysHierarchy.html
>>
>> I have implemented a view with a map function that breaks down a path
>> and using startkey/endkey, I can get a list of ALL documents for a
>> given prefix.  That was pretty straight forward, but now I am stuck
>> trying to figure out how to support 'delimiter' part.  To start, I am
>> planning on a fix delimiter '/'.  So, please let me illustrate:
>>
>> Let's assume we have five documents with following ids:
>> /beer/japan/asahi
>> /beer/japan/kirin
>> /beer/usa/oregon/rouge/deadguyale
>> /beer/usa/washingon/pikeplace/ipa
>> /sake/usa/california/gekkeikan
>> /beer   (without a trailing slash)
>> /sake  (without a trailing slash)
>>
>> My mapper emits (key : value)
>> for the first doc
>> ----------------------
>> '/' : 'beer/'
>> '/beer/' : 'japan/'
>> '/beer/japan/' : 'asahi'
>>
>> for the second doc
>> ---------------------------
>> '/' : 'beer/'
>> '/beer/' : 'japan/'
>> '/beer/japan' : 'kirin'
>>
>> for the last doc
>> ----------------------
>> '/' : 'sake'
>>
>>
>> So, If I do startkey="/beer/"&endkey="/beer/", I get
>> {"id":"/beer/japan/asahi","key":"/beer/","value":"japan/"},
>> {"id":"/beer/japan/kirin","key":"/beer/","value":"japan/"},
>> {"id":"/beer/usa/oregon/rouge/deadguyale","key":"/beer/","value":"usa/"},
>> {"id":"/beer/usa/washington/pikeplace/ipa","key":"/beer/","value":"usa/"}
>>
>> This makes sense.  I am getting all documents that contains a key
>> "/beer/".
>>
>> Now, with prefix&  delimiter search, I'd like to return a list of
>> direct descendant of a path being searched without duplicates.
>> So, I want to return something like
>> "/beer/" =>  ["japan/", "usa/"].
>> Then, I can iterate through this list and traverse down a tree.
>>
>> It feels like I should be able to reduce a map result down so that
>> it'll do what I want, but I am very much stuck..I tried to reduce map
>> results down to a list of unique values, but I cannot figure out how
>> to restrict the search so that it does what I want.
>>
>> Any help will be greatly appreciated.
>>
>> Thanks,
>> Go
>
>

Mime
View raw message