You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2008/04/03 22:18:25 UTC
svn commit: r644468 -
/incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
Author: jan
Date: Thu Apr 3 13:18:24 2008
New Revision: 644468
URL: http://svn.apache.org/viewvc?rev=644468&view=rev
Log:
Expose fulltext search API through HTML
Modified:
incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
Modified: incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl?rev=644468&r1=644467&r2=644468&view=diff
==============================================================================
--- incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl Thu Apr 3 13:18:24 2008
@@ -122,12 +122,20 @@
handle_replicate_request(_Req, _Method) ->
throw({method_not_allowed, "POST"}).
+
% Database request handlers
handle_db_request(Req, Method, {Path}) ->
UriParts = string:tokens(Path, "/"),
[DbName|Rest] = UriParts,
- handle_db_request(Req, Method, {mochiweb_util:unquote(DbName), Rest});
+ UnquotedDbName = mochiweb_util:unquote(DbName),
+ case Rest of
+ ["_fulltext"|_] ->
+ handle_db_fulltext_request(Req, Method, UnquotedDbName);
+ _ ->
+ handle_db_request(Req, Method, {UnquotedDbName, Rest})
+ end;
+
handle_db_request(Req, 'PUT', {DbName, []}) ->
case couch_server:create(DbName, []) of
@@ -363,6 +371,15 @@
handle_db_request(Req, Method, {DbName, Db, [Resource]}) ->
DocId = mochiweb_util:unquote(Resource),
handle_doc_request(Req, Method, DbName, Db, DocId).
+
+handle_db_fulltext_request(Req, Method, UnquotedDbName) ->
+ case Req:parse_qs() of
+ [{"q", Query}] ->
+ {ok, Response} = couch_ft_query:execute(UnquotedDbName, Query),
+ send_json(Req, {obj, [{ok, true} | Response]});
+ _Error ->
+ throw({no_fulltext_query, "Empty Query String"})
+ end.
handle_doc_request(Req, 'DELETE', _DbName, Db, DocId) ->
% TODO: Etag handling
Re: svn commit: r644468 - /incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
Posted by Jan Lehnardt <ja...@prima.de>.
On Apr 3, 2008, at 22:18, jan@apache.org wrote:
> Author: jan
> Date: Thu Apr 3 13:18:24 2008
> New Revision: 644468
>
> URL: http://svn.apache.org/viewvc?rev=644468&view=rev
> Log:
> Expose fulltext search API through HTML
s/HTML/HTTP/
Sorry
Jan
--