You can emit meta.id. Essentially this creates a primary key index that you can 
query for ranges.

For example

If(doc.type=foo)
Emit(meta.id);

You then query as you would with any other view.

Although remember that direct Key access will be very fast and querying using 
the view will have higher latency.

Can you share your use case to give us more insight into what you are trying to 
do?


- Dipti


On Jan 31, 2014, at 4:02 PM, 
"[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>> wrote:

I have data in documents where the document id is an important piece of 
information, but isn't found in the document itself.  I realize this may not be 
ideal, but it's what I have to work with.  For basic views this isn't much of 
an issue, since the id comes back along  with the key and value in the result 
set.  Now I'm trying to write a view that can key by that id, but I can't seem 
to actually access it (I'm not sure that the row's id even exists until after 
emit is run?)

I could do _view/myView?id="documentID" instead of 
_view/myView?key="documentID", but I'm not sure that is a good solution 
performance-wise (and even if it is, it leads to a weird situation in my code 
where I am querying some views one way and other views another way).

Is there any way I can set the key in my emit() to be the same value that the 
id in the result will be?

--
You received this message because you are subscribed to the Google Groups 
"Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to