[Groonga-commit] groonga/gcs [master] Return blank facet for "nofacet" fields

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Aug 24 20:21:09 JST 2012


YUKI Hiroshi	2012-08-24 20:21:09 +0900 (Fri, 24 Aug 2012)

  New Revision: 7f52af33e249ea18ff2ec7af3507f1d8bca763a2
  https://github.com/groonga/gcs/commit/7f52af33e249ea18ff2ec7af3507f1d8bca763a2

  Log:
    Return blank facet for "nofacet" fields

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

  Modified: lib/api/2011-02-01/search.js (+2 -2)
===================================================================
--- lib/api/2011-02-01/search.js    2012-08-24 20:14:10 +0900 (cfdbfd0)
+++ lib/api/2011-02-01/search.js    2012-08-24 20:21:09 +0900 (499a2e1)
@@ -168,10 +168,10 @@ exports.createHandler = function(context) {
           hit:             data,
           elapsedTime:     elapsedTime
         });
-        if (selectQuery.facets && selectQuery.facets.length) {
+        if (selectQuery.facets.length) {
           var facetsObject = {};
           facets.forEach(function(facet, index) {
-            var facetName = selectQuery.facets[index];
+            var facetName = selectQuery.availableFacets[index];
             facetsObject[facetName] = facet;
           });
           result.facets = facetsObject;

  Modified: lib/select-query.js (+18 -11)
===================================================================
--- lib/select-query.js    2012-08-24 20:14:10 +0900 (7493eb5)
+++ lib/select-query.js    2012-08-24 20:21:09 +0900 (4e648ed)
@@ -144,6 +144,21 @@ SelectQuery.prototype = {
     }, this)
   },
 
+  get availableFacets() {
+    if (this._availableFacets === undefined)
+      this._availableFacets = this.prepareAvailableFacets();
+    return this._availableFacets;
+  },
+  prepareAvailableFacets: function() {
+    var facetReturnableFields = this.domain.facetReturnableIndexFields
+                                  .map(function(field) {
+                                    return field.name;
+                                  });
+    return this.facets.filter(function(field) {
+      return facetReturnableFields.indexOf(field) > -1;
+    });
+  },
+
   get emptyFacets() {
     if (this._emptyFacets === undefined)
       this._emptyFacets = this.prepareEmptyFacets();
@@ -167,17 +182,9 @@ SelectQuery.prototype = {
     return this._drilldownColumns;
   },
   prepareDrilldownColumns: function() {
-    var facetReturnableFields = this.domain.facetReturnableIndexFields
-                                  .map(function(field) {
-                                    return field.name;
-                                  });
-    return this.facets
-      .filter(function(field) {
-        return facetReturnableFields.indexOf(field) > -1;
-      })
-      .map(function(field) {
-        return this.domain.getIndexField(field).columnName;
-      }, this);
+    return this.availableFacets.map(function(field) {
+      return this.domain.getIndexField(field).columnName;
+    }, this);
   },
 
   get outputColumns() {
-------------- next part --------------
HTML����������������������������...
下載 



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