[Groonga-commit] groonga/gcs [master] Accept "results-type" parameter for search API (but it doesn't work)

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Dec 12 16:58:09 JST 2012


YUKI Hiroshi	2012-12-12 16:58:09 +0900 (Wed, 12 Dec 2012)

  New Revision: 6e2577729070a9a626a5dc1e6b21d89a2fdc503f
  https://github.com/groonga/gcs/commit/6e2577729070a9a626a5dc1e6b21d89a2fdc503f

  Log:
    Accept "results-type" parameter for search API (but it doesn't work)

  Modified files:
    lib/api/2011-02-01/search.js

  Modified: lib/api/2011-02-01/search.js (+7 -1)
===================================================================
--- lib/api/2011-02-01/search.js    2012-12-12 15:15:03 +0900 (69213ad)
+++ lib/api/2011-02-01/search.js    2012-12-12 16:58:09 +0900 (d4b3d01)
@@ -135,6 +135,7 @@ function createErrorBody(options) {
 exports.createHandler = function(context, config) {
   return function(request, response) {
     var startedAt = new Date();
+    var resultType = request.query['results-type'] || 'json';
 
     var selectQuery;
     try {
@@ -142,7 +143,10 @@ exports.createHandler = function(context, config) {
     } catch(error) {
       logger.error(error);
 
-      var errorData = { rid: dummyRid };
+      var errorData = {
+            type: resultType,
+            rid:  dummyRid
+          };
       if (error.message == 'validation error') {
         errorData.messages = [error.data];
       } else {
@@ -164,6 +168,7 @@ exports.createHandler = function(context, config) {
 
         if (error) {
           var body = createErrorBody({
+            type:        resultType,
             rid:         dummyRid,
             message:     error.message,
             elapsedTime: elapsedTime
@@ -171,6 +176,7 @@ exports.createHandler = function(context, config) {
           return response.send(body, 400); // TODO
         }
         var result = createResultBody({
+          type:            resultType,
           matchExpression: selectQuery.matchExpression,
           rankExpression:  selectQuery.rankExpression,
           found:           numFoundRecords,
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index