incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Klo <>
Subject Re: How to get only a field in a document
Date Sun, 11 Dec 2011 06:24:51 GMT
List functions combined with a view would handle ranges. 

A more in depth explanation of what you are trying to do would aid the community in helping.

>From what little I've seen. My gut says you're using either a poor map design, poor document
design, or a combination of the two. 

Views take a long time to build on big collections - especially if you're enumerating many
keys on a document. But once built they don't get rebuilt unless you change the map/reduce
functions. Another thing - be sure you have couchdb logging at warn or higher. The default
info causes a ton of io chatter, which slows indexing. I'm in a similar scenario w/ millions
of docs - it was taking sometimes 24 hours or more to index with the default log level. After
raising it to warn, indexing took less than half that time. 

When comparing to relational db's, I like to think of my map function as my WHERE clause,
and then combine that with arrays for keys to filter subsets of the range. Your docs basically
need to be like 1st normal form; complete structures that you can basically apply a filter
(map function) to determine joins and essential data values you need. 

On Dec 10, 2011, at 9:02 PM, jack chrispoo <> wrote:

> Thanks Jim, I took a look at show function and it seems to work on single
> document. And now my question is: is there a way to range query a show
> function using startkey and limit parameters like querying a view?
> Thanks,
> On Fri, Dec 9, 2011 at 8:05 PM, Jim Klo <> wrote:
>> if you know the document ID that you're after, then a show function can
>> handle what you're asking without a view:
>> Jim Klo
>> Senior Software Engineer
>> Center for Software Engineering
>> SRI International
>> On Dec 9, 2011, at 4:10 PM, jack chrispoo wrote:
>>> Hi all,
>>> I am new to CouchDB and I have a question about getting data in
>> documents.
>>> I have documents like below:
>>> {
>>>  "field1":"value1",
>>>  "field2":"value2",
>>>  ....
>>> }
>>> The documents have a lot of fields and in one case I only want to get
>>> field1 from the documents. I'm wondering if there is a way to avoid
>> getting
>>> the entire document from CouchDB server because this involves a lot of
>>> unnecessary data transmission over the network? I tried creating a view
>>> which emits (doc._id,{"field1": doc.fleid1}), but indexing the view takes
>>> really long, and it doesn't seem to improve the performance. So I'm
>> curious
>>> if there is an easier way to get only a field out of a document.
>>> Thanks
>>> jack

View raw message