I don't quite understand your predicament.
But take the doc:
{"_id": "example1","my_array": [1,2,3,4,5]}
To index your lists just make a view like:
function(doc){ emit(doc.my_array, null); }
Find your doc in a view:
http://yourcouch/db/_design/dd/_view/ex?startkey=[1,2,3,4,5]&endkey=[1,2,3,4,5]
Which returns:
{"total_rows":1,"offset":0,"rows":[
{"id":"example1","key":[1,2,3,4,5],"value":null}
]}
Beware that startkey=[1,2,3,4,5]&endkey=[1,2,3,4,5] matches everything that
sorts in between.
FB
On Wed, Jul 21, 2010 at 4:33 PM, Richard Llewellyn <[email protected]>wrote:
> Thanks all for quick comments and heads up with javascript! I was under
> the
> dreamy impression that the array query value would be json encoded
> automagically.
>
> I am storing values with simple keys but json lists and dicts and would
> like
> to index these values by exposing them in a view, not as their individual
> elements (I find the many 'tag' examples) but in their entirety.
>
> >>You'll either have to json encode or hash the array and then compare
> the hashes.
>
> Ok that makes sense, but how do I query with a json encoded value? I can
> encode an array to json, and the arrays should be json already in the db,
> but how would I write the query?
>
> How do I do what I mean below? Naively replacing my_array with a json
> string eg "[1, 2, 3, 4, 5]" doesn't work.
>
> eg doc.array = [1,2,3,4,5]
>
> function(doc){
> if (doc.my_array == my_array in CLIENT ENCODED JSON)
> { emit(doc.my_array, doc);
> }}
>
> Thanks,
> Rich
>