You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Brad King <br...@gmail.com> on 2008/06/10 20:01:26 UTC

500 server error posting a view

I'm trying to create a simple ad-hoc view based on one of the wiki examples:

POST /product/_test_view HTTP/1.0
Content-Type: application/json
Content-Length: 55
Host: d0002rptdb02:5984

{
  "map" : "function(doc) { emit(null, doc); } "
}


This returns a 500 server error. Response details:

HTTP/1.0 500 Internal Server Error
Server: inets/develop
Date: Tue, 10 Jun 2008 17:56:30 GMT
Cache-Control: no-cache
Pragma: no-cache
Expires: Tue, 10 Jun 2008 17:56:30 GMT
Connection: close
Content-Type: text/plain;charset=utf-8

{"error":"EXIT","reason":"{function_clause,\n    [{mod_couch,do,\n
    [{mod,\n
{init_data,{1414,\"172.20.3.43\"},\"d0002rptdb02\"},\n
[],ip_comm,#Port<0.990>,httpd_conf_5984,\"POST\",\n
\"d0002rptdb02:5984\/product\/_test_view\",\n
\"\/product\/_test_view\",\"HTTP\/1.0\",\n              \"POST
\/product\/_test_view HTTP\/1.0\",\n
[{\"host\",\"d0002rptdb02:5984\"},\n
{\"content-length\",\"55\"},\n
{\"content-type\",\"application\/json\"}],\n              \"{\\r\\n
\\\"map\\\" : \\\"function(doc) { emit(null, doc); }
\\\"\\r\\n}\\r\\n\",\n              false},\n
{uri_parts,\"product\",\"_test_view\",[],[],[]}]},\n
{mod_couch,do,1},\n     {httpd_response,traverse_modules,2},\n
{httpd_response,generate_and_send_response,1},\n
{httpd_request_handler,handle_response,1},\n
{gen_server,handle_msg,5},\n     {proc_lib,init_p,5}]}"}

The server log says something about an unrecognized query language.
What am I doing wrong? The c# CouchBrowse application also returns a
500 for the default query, so I'm thinking its some kind of server
setup issue.

Brad

Re: 500 server error posting a view

Posted by Brad King <br...@gmail.com>.
Nevermind, the view code is fine. Getting latest from SVN fixed it!
Thanks for all the timely help.

Brad

On 6/10/08, Brad King <br...@gmail.com> wrote:
> We're going to install on another box from trunk, for starters.
>
> I'm not clear on how my JSon structure for my view is wrong though.
> Can someone elaborate? Here again is what I'm POSTing  (from the exact
> wiki page Damien linked):
>
>
> POST /product/_temp_view HTTP/1.0
> Content-Type: application/json
> Content-Length: 80
> Host: d0002rptdb02:5984
>
> {
> "language": "javascript",
> "map" : "function(doc) { emit(null, doc); }"
> }
>
>
>
> On 6/10/08, Christopher Lenz <cm...@gmx.de> wrote:
> > On 10.06.2008, at 20:18, Brad King wrote:
> > > HTTP/1.0 500 Internal Server Error
> > > Server: inets/develop
> > > Date: Tue, 10 Jun 2008 18:12:52 GMT
> > > Cache-Control: no-cache
> > > Pragma: no-cache
> > > Expires: Tue, 10 Jun 2008 18:12:52 GMT
> > > Connection: close
> > > Content-Type: text/plain;charset=utf-8
> > >
> >
> > In case this hasn't been clarified yet, you're using an old version of
> > CouchDB (either 0.7.2 or an old version from SVN) in combination with
> > documentation that has been updated for the many changes in SVN trunk.
> >
> > If you've checked out from SVN and your checkout is uptodate, you've
> > probably used the wrong (old) SVN repos. The new one is here:
> >
> >  <http://svn.apache.org/repos/asf/incubator/couchdb/trunk>
> >
> > If you're using the 0.7.2 release, well, you'll probably have to dig through
> > the Wiki to find old versions of the various documents that describe the
> > APIs in that version. Or you could try using SVN trunk, or just wait for the
> > 0.8.0 release, which we're planning to release Real Soon Now.
> >
> > Cheers,
> > --
> > Christopher Lenz
> >  cmlenz at gmx.de
> >  http://www.cmlenz.net/
> >
> >
>

Re: 500 server error posting a view

Posted by Brad King <br...@gmail.com>.
We're going to install on another box from trunk, for starters.

I'm not clear on how my JSon structure for my view is wrong though.
Can someone elaborate? Here again is what I'm POSTing  (from the exact
wiki page Damien linked):


POST /product/_temp_view HTTP/1.0
Content-Type: application/json
Content-Length: 80
Host: d0002rptdb02:5984

{
"language": "javascript",
"map" : "function(doc) { emit(null, doc); }"
}



On 6/10/08, Christopher Lenz <cm...@gmx.de> wrote:
> On 10.06.2008, at 20:18, Brad King wrote:
> > HTTP/1.0 500 Internal Server Error
> > Server: inets/develop
> > Date: Tue, 10 Jun 2008 18:12:52 GMT
> > Cache-Control: no-cache
> > Pragma: no-cache
> > Expires: Tue, 10 Jun 2008 18:12:52 GMT
> > Connection: close
> > Content-Type: text/plain;charset=utf-8
> >
>
> In case this hasn't been clarified yet, you're using an old version of
> CouchDB (either 0.7.2 or an old version from SVN) in combination with
> documentation that has been updated for the many changes in SVN trunk.
>
> If you've checked out from SVN and your checkout is uptodate, you've
> probably used the wrong (old) SVN repos. The new one is here:
>
>  <http://svn.apache.org/repos/asf/incubator/couchdb/trunk>
>
> If you're using the 0.7.2 release, well, you'll probably have to dig through
> the Wiki to find old versions of the various documents that describe the
> APIs in that version. Or you could try using SVN trunk, or just wait for the
> 0.8.0 release, which we're planning to release Real Soon Now.
>
> Cheers,
> --
> Christopher Lenz
>  cmlenz at gmx.de
>  http://www.cmlenz.net/
>
>

Re: 500 server error posting a view

Posted by Christopher Lenz <cm...@gmx.de>.
On 10.06.2008, at 20:18, Brad King wrote:
> HTTP/1.0 500 Internal Server Error
> Server: inets/develop
> Date: Tue, 10 Jun 2008 18:12:52 GMT
> Cache-Control: no-cache
> Pragma: no-cache
> Expires: Tue, 10 Jun 2008 18:12:52 GMT
> Connection: close
> Content-Type: text/plain;charset=utf-8

In case this hasn't been clarified yet, you're using an old version of  
CouchDB (either 0.7.2 or an old version from SVN) in combination with  
documentation that has been updated for the many changes in SVN trunk.

If you've checked out from SVN and your checkout is uptodate, you've  
probably used the wrong (old) SVN repos. The new one is here:

   <http://svn.apache.org/repos/asf/incubator/couchdb/trunk>

If you're using the 0.7.2 release, well, you'll probably have to dig  
through the Wiki to find old versions of the various documents that  
describe the APIs in that version. Or you could try using SVN trunk,  
or just wait for the 0.8.0 release, which we're planning to release  
Real Soon Now.

Cheers,
--
Christopher Lenz
   cmlenz at gmx.de
   http://www.cmlenz.net/


Re: 500 server error posting a view

Posted by Chris Anderson <jc...@grabb.it>.
Brad,

It's starting to sound like you might have an aberrant checkout -
maybe try starting from scratch with a new checkout of

http://svn.apache.org/repos/asf/incubator/couchdb/trunk

and see if that helps. For instance, the text/javascript => javascript
transition is pretty recent, as is the use of application/json as the
mime type.



On Tue, Jun 10, 2008 at 12:25 PM, Brad King <br...@gmail.com> wrote:
> When I remove the text/ prefix I still get the 500 error, and the
> query interface in the browser starts throwing "undefined" alert
> boxes. One thing I find confusing is the error is saying
> application/json is not a defined query language. Is my POST supposed
> to have Content-Type application/json or text/javascript? I see a mix
> of both here:
>
> http://wiki.apache.org/couchdb/Views
>
> "Temporary views are not stored in the database, but rather executed
> on demand. To execute a temporary view, you make an HTTP POST request
> to the URI /{dbname}/_temp_view, where the body of the request
> contains the code of the view function and the Content-Type header is
> set to text/javascript. "
>
> OR
>
> http://wiki.apache.org/couchdb/HttpViewApi
>
> "Ad Hoc Views
> One-off queries (eg. views you don't want to save in the CouchDB
> database) can be done via the special view _temp_view:
>
> POST /some_database/_temp_view  HTTP/1.0
> Content-Length: 48
> Date: Mon, 10 Sep 2007 17:11:10 +0200
> Content-Type: application/json
>
> {
>  "map" : "function(doc) { if (doc.foo=='bar') { emit(null, doc.foo); } }"
> }
> "
>
> Seems like conflicting info to accomplish the same thing.
>
>
>
> On 6/10/08, Jan Lehnardt <ja...@apache.org> wrote:
>>
>> On Jun 10, 2008, at 21:03, Brad King wrote:
>>
>> > I tried adding the "language" specifier, but no change. The couch.ini
>> > section you mentioned looks like this:
>> >
>> > [Couch Query Servers]
>> >
>> > text/javascript=/usr/local/bin/couchjs -f
>> > /usr/local/share/couchdb/server/main.js
>> >
>>
>> drop the "text/" prefix and try again,
>>
>> thx,
>> Jan
>> --
>>
>>
>> >
>> >
>> >
>> > On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
>> >
>> > > Brad,
>> > >
>> > > there's an (optional) parameter on view json. try this:
>> > >
>> > > {
>> > > "language": "javascript",
>> > > "map" : "function(doc) { emit(null, doc); } "
>> > > }
>> > >
>> > > although "javascript" is supposed to be the default, so it makes me
>> > > wonder if something else s the source of your error.
>> > >
>> > > The problem could be with your couch.ini file -
>> > > /usr/local/etc/couchdb/couch.ini should have a line in
>> it like this
>> > > (which is also the default):
>> > >
>> > > [Couch Query Servers]
>> > >
>> > > javascript=/usr/local/bin/couchjs
>> /usr/local/share/couchdb/server/main.js
>> > >
>> > >
>> > > On Tue, Jun 10, 2008 at 11:18 AM, Brad King <br...@gmail.com> wrote:
>> > >
>> > > > Chris: ah, yes I screwed up the URL, however I still get the 500 after
>> > > > fixing this:
>> > > >
>> > > > POST /product/_temp_view HTTP/1.0
>> > > > Content-Type: application/json
>> > > > Content-Length: 55
>> > > > Host: d0002rptdb02:5984
>> > > >
>> > > > {
>> > > > "map" : "function(doc) { emit(null, doc); } "
>> > > > }
>> > > >
>> > > > Different error though
>> > > >
>> > > > HTTP/1.0 500 Internal Server Error
>> > > > Server: inets/develop
>> > > > Date: Tue, 10 Jun 2008 18:12:52 GMT
>> > > > Cache-Control: no-cache
>> > > > Pragma: no-cache
>> > > > Expires: Tue, 10 Jun 2008 18:12:52 GMT
>> > > > Connection: close
>> > > > Content-Type: text/plain;charset=utf-8
>> > > >
>> > > >
>> {"error":"query_language_unknown","reason":"application\/json"}
>> > > >
>> > > >
>> > > > Jan, this is the correct format for an ad-hoc view, no? the page you
>> > > > linked me to is where I got the info.
>> > > >
>> > > > BTW I can browse the database just fine with a web browser, and the
>> > > > default query runs ok in a browser as well.
>> > > >
>> > > > Thanks
>> > > >
>> > > > On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
>> > > >
>> > > > > Brad,
>> > > > >
>> > > > > It look like the url:
>> > > > >
>> > > > >
>> > > > > > POST /product/_test_view HTTP/1.0
>> > > > > >
>> > > > > >
>> > > > >
>> > > > > should be /product/_design/test_view (for a named view)
>> > > > >
>> > > > > or /product/_temp_view
>> > > > >
>> > > > > assuming your db name is product.
>> > > > >
>> > > > > Hope that helps.
>> > > > >
>> > > > > Chris
>> > > > >
>> > > > > --
>> > > > > Chris Anderson
>> > > > > http://jchris.mfdz.com
>> > > > >
>> > > > >
>> > > >
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Chris Anderson
>> > > http://jchris.mfdz.com
>> > >
>> > >
>> >
>> >
>>
>>
>



-- 
Chris Anderson
http://jchris.mfdz.com

Re: 500 server error posting a view

Posted by Damien Katz <da...@gmail.com>.
The format of your design document is wrong. You need to have the view  
defined using specific json structure like in the example here: http://wiki.apache.org/couchdb/HttpViewApi


On Jun 10, 2008, at 3:25 PM, Brad King wrote:

> When I remove the text/ prefix I still get the 500 error, and the
> query interface in the browser starts throwing "undefined" alert
> boxes. One thing I find confusing is the error is saying
> application/json is not a defined query language. Is my POST supposed
> to have Content-Type application/json or text/javascript? I see a mix
> of both here:
>
> http://wiki.apache.org/couchdb/Views
>
> "Temporary views are not stored in the database, but rather executed
> on demand. To execute a temporary view, you make an HTTP POST request
> to the URI /{dbname}/_temp_view, where the body of the request
> contains the code of the view function and the Content-Type header is
> set to text/javascript. "
>
> OR
>
> http://wiki.apache.org/couchdb/HttpViewApi
>
> "Ad Hoc Views
> One-off queries (eg. views you don't want to save in the CouchDB
> database) can be done via the special view _temp_view:
>
> POST /some_database/_temp_view  HTTP/1.0
> Content-Length: 48
> Date: Mon, 10 Sep 2007 17:11:10 +0200
> Content-Type: application/json
>
> {
>  "map" : "function(doc) { if (doc.foo=='bar') { emit(null,  
> doc.foo); } }"
> }
> "
>
> Seems like conflicting info to accomplish the same thing.
>
>
>
> On 6/10/08, Jan Lehnardt <ja...@apache.org> wrote:
>>
>> On Jun 10, 2008, at 21:03, Brad King wrote:
>>
>>> I tried adding the "language" specifier, but no change. The  
>>> couch.ini
>>> section you mentioned looks like this:
>>>
>>> [Couch Query Servers]
>>>
>>> text/javascript=/usr/local/bin/couchjs -f
>>> /usr/local/share/couchdb/server/main.js
>>>
>>
>> drop the "text/" prefix and try again,
>>
>> thx,
>> Jan
>> --
>>
>>
>>>
>>>
>>>
>>> On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
>>>
>>>> Brad,
>>>>
>>>> there's an (optional) parameter on view json. try this:
>>>>
>>>> {
>>>> "language": "javascript",
>>>> "map" : "function(doc) { emit(null, doc); } "
>>>> }
>>>>
>>>> although "javascript" is supposed to be the default, so it makes me
>>>> wonder if something else s the source of your error.
>>>>
>>>> The problem could be with your couch.ini file -
>>>> /usr/local/etc/couchdb/couch.ini should have a line in
>> it like this
>>>> (which is also the default):
>>>>
>>>> [Couch Query Servers]
>>>>
>>>> javascript=/usr/local/bin/couchjs
>> /usr/local/share/couchdb/server/main.js
>>>>
>>>>
>>>> On Tue, Jun 10, 2008 at 11:18 AM, Brad King <br...@gmail.com>  
>>>> wrote:
>>>>
>>>>> Chris: ah, yes I screwed up the URL, however I still get the 500  
>>>>> after
>>>>> fixing this:
>>>>>
>>>>> POST /product/_temp_view HTTP/1.0
>>>>> Content-Type: application/json
>>>>> Content-Length: 55
>>>>> Host: d0002rptdb02:5984
>>>>>
>>>>> {
>>>>> "map" : "function(doc) { emit(null, doc); } "
>>>>> }
>>>>>
>>>>> Different error though
>>>>>
>>>>> HTTP/1.0 500 Internal Server Error
>>>>> Server: inets/develop
>>>>> Date: Tue, 10 Jun 2008 18:12:52 GMT
>>>>> Cache-Control: no-cache
>>>>> Pragma: no-cache
>>>>> Expires: Tue, 10 Jun 2008 18:12:52 GMT
>>>>> Connection: close
>>>>> Content-Type: text/plain;charset=utf-8
>>>>>
>>>>>
>> {"error":"query_language_unknown","reason":"application\/json"}
>>>>>
>>>>>
>>>>> Jan, this is the correct format for an ad-hoc view, no? the page  
>>>>> you
>>>>> linked me to is where I got the info.
>>>>>
>>>>> BTW I can browse the database just fine with a web browser, and  
>>>>> the
>>>>> default query runs ok in a browser as well.
>>>>>
>>>>> Thanks
>>>>>
>>>>> On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
>>>>>
>>>>>> Brad,
>>>>>>
>>>>>> It look like the url:
>>>>>>
>>>>>>
>>>>>>> POST /product/_test_view HTTP/1.0
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> should be /product/_design/test_view (for a named view)
>>>>>>
>>>>>> or /product/_temp_view
>>>>>>
>>>>>> assuming your db name is product.
>>>>>>
>>>>>> Hope that helps.
>>>>>>
>>>>>> Chris
>>>>>>
>>>>>> --
>>>>>> Chris Anderson
>>>>>> http://jchris.mfdz.com
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Chris Anderson
>>>> http://jchris.mfdz.com
>>>>
>>>>
>>>
>>>
>>
>>


Re: 500 server error posting a view

Posted by Brad King <br...@gmail.com>.
When I remove the text/ prefix I still get the 500 error, and the
query interface in the browser starts throwing "undefined" alert
boxes. One thing I find confusing is the error is saying
application/json is not a defined query language. Is my POST supposed
to have Content-Type application/json or text/javascript? I see a mix
of both here:

http://wiki.apache.org/couchdb/Views

"Temporary views are not stored in the database, but rather executed
on demand. To execute a temporary view, you make an HTTP POST request
to the URI /{dbname}/_temp_view, where the body of the request
contains the code of the view function and the Content-Type header is
set to text/javascript. "

OR

http://wiki.apache.org/couchdb/HttpViewApi

"Ad Hoc Views
One-off queries (eg. views you don't want to save in the CouchDB
database) can be done via the special view _temp_view:

POST /some_database/_temp_view  HTTP/1.0
Content-Length: 48
Date: Mon, 10 Sep 2007 17:11:10 +0200
Content-Type: application/json

{
  "map" : "function(doc) { if (doc.foo=='bar') { emit(null, doc.foo); } }"
}
"

Seems like conflicting info to accomplish the same thing.



On 6/10/08, Jan Lehnardt <ja...@apache.org> wrote:
>
> On Jun 10, 2008, at 21:03, Brad King wrote:
>
> > I tried adding the "language" specifier, but no change. The couch.ini
> > section you mentioned looks like this:
> >
> > [Couch Query Servers]
> >
> > text/javascript=/usr/local/bin/couchjs -f
> > /usr/local/share/couchdb/server/main.js
> >
>
> drop the "text/" prefix and try again,
>
> thx,
> Jan
> --
>
>
> >
> >
> >
> > On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
> >
> > > Brad,
> > >
> > > there's an (optional) parameter on view json. try this:
> > >
> > > {
> > > "language": "javascript",
> > > "map" : "function(doc) { emit(null, doc); } "
> > > }
> > >
> > > although "javascript" is supposed to be the default, so it makes me
> > > wonder if something else s the source of your error.
> > >
> > > The problem could be with your couch.ini file -
> > > /usr/local/etc/couchdb/couch.ini should have a line in
> it like this
> > > (which is also the default):
> > >
> > > [Couch Query Servers]
> > >
> > > javascript=/usr/local/bin/couchjs
> /usr/local/share/couchdb/server/main.js
> > >
> > >
> > > On Tue, Jun 10, 2008 at 11:18 AM, Brad King <br...@gmail.com> wrote:
> > >
> > > > Chris: ah, yes I screwed up the URL, however I still get the 500 after
> > > > fixing this:
> > > >
> > > > POST /product/_temp_view HTTP/1.0
> > > > Content-Type: application/json
> > > > Content-Length: 55
> > > > Host: d0002rptdb02:5984
> > > >
> > > > {
> > > > "map" : "function(doc) { emit(null, doc); } "
> > > > }
> > > >
> > > > Different error though
> > > >
> > > > HTTP/1.0 500 Internal Server Error
> > > > Server: inets/develop
> > > > Date: Tue, 10 Jun 2008 18:12:52 GMT
> > > > Cache-Control: no-cache
> > > > Pragma: no-cache
> > > > Expires: Tue, 10 Jun 2008 18:12:52 GMT
> > > > Connection: close
> > > > Content-Type: text/plain;charset=utf-8
> > > >
> > > >
> {"error":"query_language_unknown","reason":"application\/json"}
> > > >
> > > >
> > > > Jan, this is the correct format for an ad-hoc view, no? the page you
> > > > linked me to is where I got the info.
> > > >
> > > > BTW I can browse the database just fine with a web browser, and the
> > > > default query runs ok in a browser as well.
> > > >
> > > > Thanks
> > > >
> > > > On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
> > > >
> > > > > Brad,
> > > > >
> > > > > It look like the url:
> > > > >
> > > > >
> > > > > > POST /product/_test_view HTTP/1.0
> > > > > >
> > > > > >
> > > > >
> > > > > should be /product/_design/test_view (for a named view)
> > > > >
> > > > > or /product/_temp_view
> > > > >
> > > > > assuming your db name is product.
> > > > >
> > > > > Hope that helps.
> > > > >
> > > > > Chris
> > > > >
> > > > > --
> > > > > Chris Anderson
> > > > > http://jchris.mfdz.com
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Chris Anderson
> > > http://jchris.mfdz.com
> > >
> > >
> >
> >
>
>

Re: 500 server error posting a view

Posted by Jan Lehnardt <ja...@apache.org>.
On Jun 10, 2008, at 21:03, Brad King wrote:

> I tried adding the "language" specifier, but no change. The couch.ini
> section you mentioned looks like this:
>
> [Couch Query Servers]
>
> text/javascript=/usr/local/bin/couchjs -f
> /usr/local/share/couchdb/server/main.js

drop the "text/" prefix and try again,

thx,
Jan
--

>
>
>
> On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
>> Brad,
>>
>> there's an (optional) parameter on view json. try this:
>>
>> {
>> "language": "javascript",
>> "map" : "function(doc) { emit(null, doc); } "
>> }
>>
>> although "javascript" is supposed to be the default, so it makes me
>> wonder if something else s the source of your error.
>>
>> The problem could be with your couch.ini file -
>> /usr/local/etc/couchdb/couch.ini should have a line in it like this
>> (which is also the default):
>>
>> [Couch Query Servers]
>>
>> javascript=/usr/local/bin/couchjs /usr/local/share/couchdb/server/ 
>> main.js
>>
>>
>> On Tue, Jun 10, 2008 at 11:18 AM, Brad King <br...@gmail.com> wrote:
>>> Chris: ah, yes I screwed up the URL, however I still get the 500  
>>> after
>>> fixing this:
>>>
>>> POST /product/_temp_view HTTP/1.0
>>> Content-Type: application/json
>>> Content-Length: 55
>>> Host: d0002rptdb02:5984
>>>
>>> {
>>> "map" : "function(doc) { emit(null, doc); } "
>>> }
>>>
>>> Different error though
>>>
>>> HTTP/1.0 500 Internal Server Error
>>> Server: inets/develop
>>> Date: Tue, 10 Jun 2008 18:12:52 GMT
>>> Cache-Control: no-cache
>>> Pragma: no-cache
>>> Expires: Tue, 10 Jun 2008 18:12:52 GMT
>>> Connection: close
>>> Content-Type: text/plain;charset=utf-8
>>>
>>> {"error":"query_language_unknown","reason":"application\/json"}
>>>
>>>
>>> Jan, this is the correct format for an ad-hoc view, no? the page you
>>> linked me to is where I got the info.
>>>
>>> BTW I can browse the database just fine with a web browser, and the
>>> default query runs ok in a browser as well.
>>>
>>> Thanks
>>>
>>> On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
>>>> Brad,
>>>>
>>>> It look like the url:
>>>>
>>>>> POST /product/_test_view HTTP/1.0
>>>>>
>>>>
>>>> should be /product/_design/test_view (for a named view)
>>>>
>>>> or /product/_temp_view
>>>>
>>>> assuming your db name is product.
>>>>
>>>> Hope that helps.
>>>>
>>>> Chris
>>>>
>>>> --
>>>> Chris Anderson
>>>> http://jchris.mfdz.com
>>>>
>>>
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchris.mfdz.com
>>
>


Re: 500 server error posting a view

Posted by Brad King <br...@gmail.com>.
I tried adding the "language" specifier, but no change. The couch.ini
section you mentioned looks like this:

[Couch Query Servers]

text/javascript=/usr/local/bin/couchjs -f
/usr/local/share/couchdb/server/main.js


On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
> Brad,
>
> there's an (optional) parameter on view json. try this:
>
>  {
>  "language": "javascript",
>  "map" : "function(doc) { emit(null, doc); } "
>  }
>
> although "javascript" is supposed to be the default, so it makes me
> wonder if something else s the source of your error.
>
> The problem could be with your couch.ini file -
> /usr/local/etc/couchdb/couch.ini should have a line in it like this
> (which is also the default):
>
> [Couch Query Servers]
>
> javascript=/usr/local/bin/couchjs /usr/local/share/couchdb/server/main.js
>
>
> On Tue, Jun 10, 2008 at 11:18 AM, Brad King <br...@gmail.com> wrote:
> > Chris: ah, yes I screwed up the URL, however I still get the 500 after
> > fixing this:
> >
> > POST /product/_temp_view HTTP/1.0
> > Content-Type: application/json
> > Content-Length: 55
> > Host: d0002rptdb02:5984
> >
> > {
> >  "map" : "function(doc) { emit(null, doc); } "
> > }
> >
> > Different error though
> >
> > HTTP/1.0 500 Internal Server Error
> > Server: inets/develop
> > Date: Tue, 10 Jun 2008 18:12:52 GMT
> > Cache-Control: no-cache
> > Pragma: no-cache
> > Expires: Tue, 10 Jun 2008 18:12:52 GMT
> > Connection: close
> > Content-Type: text/plain;charset=utf-8
> >
> > {"error":"query_language_unknown","reason":"application\/json"}
> >
> >
> > Jan, this is the correct format for an ad-hoc view, no? the page you
> > linked me to is where I got the info.
> >
> > BTW I can browse the database just fine with a web browser, and the
> > default query runs ok in a browser as well.
> >
> > Thanks
> >
> > On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
> >> Brad,
> >>
> >> It look like the url:
> >>
> >> > POST /product/_test_view HTTP/1.0
> >> >
> >>
> >> should be /product/_design/test_view (for a named view)
> >>
> >> or /product/_temp_view
> >>
> >> assuming your db name is product.
> >>
> >> Hope that helps.
> >>
> >> Chris
> >>
> >> --
> >> Chris Anderson
> >> http://jchris.mfdz.com
> >>
> >
>
>
>
> --
> Chris Anderson
> http://jchris.mfdz.com
>

Re: 500 server error posting a view

Posted by Chris Anderson <jc...@grabb.it>.
Brad,

there's an (optional) parameter on view json. try this:

 {
  "language": "javascript",
  "map" : "function(doc) { emit(null, doc); } "
 }

although "javascript" is supposed to be the default, so it makes me
wonder if something else s the source of your error.

The problem could be with your couch.ini file -
/usr/local/etc/couchdb/couch.ini should have a line in it like this
(which is also the default):

[Couch Query Servers]

javascript=/usr/local/bin/couchjs /usr/local/share/couchdb/server/main.js


On Tue, Jun 10, 2008 at 11:18 AM, Brad King <br...@gmail.com> wrote:
> Chris: ah, yes I screwed up the URL, however I still get the 500 after
> fixing this:
>
> POST /product/_temp_view HTTP/1.0
> Content-Type: application/json
> Content-Length: 55
> Host: d0002rptdb02:5984
>
> {
>  "map" : "function(doc) { emit(null, doc); } "
> }
>
> Different error though
>
> HTTP/1.0 500 Internal Server Error
> Server: inets/develop
> Date: Tue, 10 Jun 2008 18:12:52 GMT
> Cache-Control: no-cache
> Pragma: no-cache
> Expires: Tue, 10 Jun 2008 18:12:52 GMT
> Connection: close
> Content-Type: text/plain;charset=utf-8
>
> {"error":"query_language_unknown","reason":"application\/json"}
>
>
> Jan, this is the correct format for an ad-hoc view, no? the page you
> linked me to is where I got the info.
>
> BTW I can browse the database just fine with a web browser, and the
> default query runs ok in a browser as well.
>
> Thanks
>
> On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
>> Brad,
>>
>> It look like the url:
>>
>> > POST /product/_test_view HTTP/1.0
>> >
>>
>> should be /product/_design/test_view (for a named view)
>>
>> or /product/_temp_view
>>
>> assuming your db name is product.
>>
>> Hope that helps.
>>
>> Chris
>>
>> --
>> Chris Anderson
>> http://jchris.mfdz.com
>>
>



-- 
Chris Anderson
http://jchris.mfdz.com

Re: 500 server error posting a view

Posted by Brad King <br...@gmail.com>.
Chris: ah, yes I screwed up the URL, however I still get the 500 after
fixing this:

POST /product/_temp_view HTTP/1.0
Content-Type: application/json
Content-Length: 55
Host: d0002rptdb02:5984

{
  "map" : "function(doc) { emit(null, doc); } "
}

Different error though

HTTP/1.0 500 Internal Server Error
Server: inets/develop
Date: Tue, 10 Jun 2008 18:12:52 GMT
Cache-Control: no-cache
Pragma: no-cache
Expires: Tue, 10 Jun 2008 18:12:52 GMT
Connection: close
Content-Type: text/plain;charset=utf-8

{"error":"query_language_unknown","reason":"application\/json"}


Jan, this is the correct format for an ad-hoc view, no? the page you
linked me to is where I got the info.

BTW I can browse the database just fine with a web browser, and the
default query runs ok in a browser as well.

Thanks

On 6/10/08, Chris Anderson <jc...@grabb.it> wrote:
> Brad,
>
> It look like the url:
>
> > POST /product/_test_view HTTP/1.0
> >
>
> should be /product/_design/test_view (for a named view)
>
> or /product/_temp_view
>
> assuming your db name is product.
>
> Hope that helps.
>
> Chris
>
> --
> Chris Anderson
> http://jchris.mfdz.com
>

Re: 500 server error posting a view

Posted by Chris Anderson <jc...@grabb.it>.
Brad,

It look like the url:

> POST /product/_test_view HTTP/1.0
>

should be /product/_design/test_view (for a named view)

or /product/_temp_view

assuming your db name is product.

Hope that helps.

Chris

-- 
Chris Anderson
http://jchris.mfdz.com

Re: 500 server error posting a view

Posted by Jan Lehnardt <ja...@apache.org>.
Heya Brad,
your design document definition is incomplete see
http://wiki.apache.org/couchdb/HttpViewApi
"Creating Views" for how a complete design doc
needs to look like.

Cheers
Jan

On Jun 10, 2008, at 20:01, Brad King wrote:

> I'm trying to create a simple ad-hoc view based on one of the wiki  
> examples:
>
> POST /product/_test_view HTTP/1.0
> Content-Type: application/json
> Content-Length: 55
> Host: d0002rptdb02:5984
>
> {
>  "map" : "function(doc) { emit(null, doc); } "
> }
>
>
> This returns a 500 server error. Response details:
>
> HTTP/1.0 500 Internal Server Error
> Server: inets/develop
> Date: Tue, 10 Jun 2008 17:56:30 GMT
> Cache-Control: no-cache
> Pragma: no-cache
> Expires: Tue, 10 Jun 2008 17:56:30 GMT
> Connection: close
> Content-Type: text/plain;charset=utf-8
>
> {"error":"EXIT","reason":"{function_clause,\n    [{mod_couch,do,\n
>    [{mod,\n
> {init_data,{1414,\"172.20.3.43\"},\"d0002rptdb02\"},\n
> [],ip_comm,#Port<0.990>,httpd_conf_5984,\"POST\",\n
> \"d0002rptdb02:5984\/product\/_test_view\",\n
> \"\/product\/_test_view\",\"HTTP\/1.0\",\n              \"POST
> \/product\/_test_view HTTP\/1.0\",\n
> [{\"host\",\"d0002rptdb02:5984\"},\n
> {\"content-length\",\"55\"},\n
> {\"content-type\",\"application\/json\"}],\n              \"{\\r\\n
> \\\"map\\\" : \\\"function(doc) { emit(null, doc); }
> \\\"\\r\\n}\\r\\n\",\n              false},\n
> {uri_parts,\"product\",\"_test_view\",[],[],[]}]},\n
> {mod_couch,do,1},\n     {httpd_response,traverse_modules,2},\n
> {httpd_response,generate_and_send_response,1},\n
> {httpd_request_handler,handle_response,1},\n
> {gen_server,handle_msg,5},\n     {proc_lib,init_p,5}]}"}
>
> The server log says something about an unrecognized query language.
> What am I doing wrong? The c# CouchBrowse application also returns a
> 500 for the default query, so I'm thinking its some kind of server
> setup issue.
>
> Brad
>