couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r644468 - /incubator/couchdb/branches/mochiweb/src/couchdb/couch_httpd.erl
Date Thu, 03 Apr 2008 20:18:25 GMT
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



Mime
View raw message