doc type and indexing
Wed, 02/06/2013 - 07:37
In an example that I saw in creating an index/view I see:
function(doc, meta) {
if(doc.type == "brewery" && doc.city) {
emit(doc.city, null);
}
}
My question is what determines the doc.type? I would be writing a document like:
client.Store(StoreMode.Add, destination.SKU, destination);
Which argument on the store determines the doc.type?
Thu, 02/07/2013 - 06:17
Thank you. These two links are invalid. They cannot be resolved.
Thu, 02/07/2013 - 09:22
Strange they do work for me let me put shorter version of it:
- http://goo.gl/pIrWR
- http://goo.gl/h3oGV
Hello,
The short answer is : "You as a developer determine the doc type".
Couchbase allows you to store "anything" up to 20Mb, when you store JSON document they will be indexed by the views.
But the document are not "typed" by the server, so when you want to execute specific treatments, as you describe in the view above you have to type the document yourself.
This is usually done with a json attribute called "type", but you can use any type you want.
I am inviting your to look at this chapter about document modeling in the "Couchbase Developer Guide"
- http://www.couchbase.com/docs/couchbase-devguide-2.0/modeling-documents....
and especially :
- http://www.couchbase.com/docs/couchbase-devguide-2.0/working-with-out-sc...
HTH
Tug
@tgrall