[
https://issues.apache.org/jira/browse/COUCHDB-1868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13737180#comment-13737180
]
Jan Lehnardt commented on COUCHDB-1868:
---------------------------------------
Excellent, very happy to help you get started writing a patch :D
The view engine code is in CouchDB’s src/couch_mrview directory (the indexing
is actually separately in src/couch_index, but we need couhc_mrview here).
See e.g. https://github.com/apache/couchdb/tree/master/src/couch_mrview/src
This is where we handle the POST request to regular views:
https://github.com/apache/couchdb/blob/master/src/couch_mrview/src/couch_mrview_http.erl#L52
This is where we handle _all_docs requests:
https://github.com/apache/couchdb/blob/master/src/couch_mrview/src/couch_mrview_http.erl#L39
but that only refers to
https://github.com/apache/couchdb/blob/master/src/couch_mrview/src/couch_mrview_http.erl#L133
further down which in turn refers to
https://github.com/apache/couchdb/blob/master/src/couch_mrview/src/couch_mrview.erl#L48
and then
https://github.com/apache/couchdb/blob/master/src/couch_mrview/src/couch_mrview.erl#L119
which injects the not_found at
https://github.com/apache/couchdb/blob/master/src/couch_mrview/src/couch_mrview.erl#L167
I leave finding the chain for regular views to you, just follow the same clues
down from the API call :)
Erlang function calls are of the form modulename:function() and module names
are reflected in filenames, either under src/*.erl or src/couchdb/*.erl
Let us know if you have any more questions.
> Using multiple keys, the _all_docs built-in view acts differently then a user
> defined view
> ------------------------------------------------------------------------------------------
>
> Key: COUCHDB-1868
> URL: https://issues.apache.org/jira/browse/COUCHDB-1868
> Project: CouchDB
> Issue Type: Bug
> Components: View Server Support
> Reporter: Filippo Fadda
>
> When you query a view using multiple keys, the _all_docs built-in view acts
> differently then a user defined view:
> 1) in the first case CouchDB returns "not_found" for every not found key;
> 2) querying a user defined view produces, instead, an empty array.
> In the first case you obtain error="not_found" for every key, when you query
> a user defined view you simply don't get any rows, just the total rows for
> the view.
> See: http://pastebin.com/D7NExJrd
> Now, regarding 'keys' the documentation says something like: "Used to
> retrieve just the view rows matching that set of keys. Rows are returned in
> the order of the specified keys."
> In a normal case, CouchDB should return just a row for each matched key, but
> it will really help, having an option to return a row for every key, even
> there if not found, because it's more easy, cycle through results.
> Let's suppose the application I'm doing gets the last 30 blog posts,
> displaying for each one, information that are stored into related documents.
> The application will query, using as keys the posts' identifiers, other views
> to get, for example, if a post has been starred from the current logged-in
> user, etc.
> If a view always returns a number of rows equals to the number of keys, the
> application can cycle from 0 to 29 and display all the related information
> for a post.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira