[Groonga-commit] groonga/groonga-admin at 45880c3 [master] Support full text search of reference type column

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Sun Dec 21 16:56:09 JST 2014


Kouhei Sutou	2014-12-21 16:56:09 +0900 (Sun, 21 Dec 2014)

  New Revision: 45880c3476a4051a07e211d7d9cc7dae397dc2d4
  https://github.com/groonga/groonga-admin/commit/45880c3476a4051a07e211d7d9cc7dae397dc2d4

  Message:
    Support full text search of reference type column

  Modified files:
    app/scripts/controllers/table-search-controller.js
    app/scripts/services/schema-loader.js

  Modified: app/scripts/controllers/table-search-controller.js (+51 -27)
===================================================================
--- app/scripts/controllers/table-search-controller.js    2014-12-21 16:28:33 +0900 (633abb1)
+++ app/scripts/controllers/table-search-controller.js    2014-12-21 16:56:09 +0900 (c37d4ed)
@@ -237,7 +237,7 @@ angular.module('groongaAdminApp')
           return column.name === key;
         });
         if (column) {
-          if (column.isTableType) {
+          if (column.valueType.isReferenceType) {
             queryKey += '._key';
           }
         }
@@ -296,39 +296,63 @@ angular.module('groongaAdminApp')
           drilldown: drilldown,
           sort: sort,
           indexes: column.indexes || [],
-          isTextType: column.isTextType,
-          isTableType: column.isTableType
+          valueType: column.valueType
         };
       }
 
-      function addColumn(columnInfo) {
-        $scope.table.allColumns.push(columnInfo);
+      function addTimeColumn(columnInfo) {
+        if (columnInfo.type !== 'Time') {
+          return;
+        }
+
+        var timeColumnInfo = {
+          name: columnInfo.name,
+          start: null,
+          startIncluded: true,
+          end: null,
+          endIncluded: true
+        };
+        $scope.table.timeColumns.push(timeColumnInfo);
+      }
+
+      function addIndexedColumn(columnInfo) {
+        if (columnInfo.indexes.length === 0) {
+          return;
+        }
 
-        if (columnInfo.type === 'Time') {
-          var timeColumnInfo = {
-            name: columnInfo.name,
-            start: null,
-            startIncluded: true,
-            end: null,
-            endIncluded: true
-          };
-          $scope.table.timeColumns.push(timeColumnInfo);
+        var isTextType = false;
+        if (columnInfo.valueType.isReferenceType) {
+          var table = schema.tables[columnInfo.valueType.name];
+          isTextType = table.keyType.isTextType;
+        } else {
+          isTextType = columnInfo.valueType.isTextType;
+        }
+
+        if (!isTextType) {
+          return;
         }
 
         var matchColumns = $scope.parameters.match_columns;
-        columnInfo.indexes.forEach(function(/* index */) {
-          var indexName = columnInfo.name;
-          var inUse = true;
-          if (matchColumns) {
-            inUse = (matchColumns.indexOf(indexName) !== -1);
-          }
-          var indexedColumnInfo = {
-            name: columnInfo.name,
-            indexName: indexName,
-            inUse: inUse
-          };
-          $scope.table.indexedColumns.push(indexedColumnInfo);
-        });
+        var indexName = columnInfo.name;
+        if (columnInfo.valueType.isReferenceType) {
+          indexName += '._key';
+        }
+        var inUse = true;
+        if (matchColumns) {
+          inUse = (matchColumns.indexOf(indexName) !== -1);
+        }
+        var indexedColumnInfo = {
+          name: columnInfo.name,
+          indexName: indexName,
+          inUse: inUse
+        };
+        $scope.table.indexedColumns.push(indexedColumnInfo);
+      }
+
+      function addColumn(columnInfo) {
+        $scope.table.allColumns.push(columnInfo);
+        addTimeColumn(columnInfo);
+        addIndexedColumn(columnInfo);
       }
 
       function applyTimeQueries() {

  Modified: app/scripts/services/schema-loader.js (+19 -2)
===================================================================
--- app/scripts/services/schema-loader.js    2014-12-21 16:28:33 +0900 (3581d06)
+++ app/scripts/services/schema-loader.js    2014-12-21 16:56:09 +0900 (1436960)
@@ -34,9 +34,25 @@ angular.module('groongaAdminApp')
         return typeName in schema.tables;
       }
 
+      function resolveTable(table) {
+        table.keyType = {
+          name: table.domain,
+          isTextType: isTextType(table.domain)
+        };
+      }
+
+      function resolveTables() {
+        angular.forEach(schema.tables, function(table) {
+          resolveTable(table);
+        });
+      }
+
       function resolveColumn(column) {
-        column.isTextType = isTextType(column.range);
-        column.isReferenceType = isReferenceType(column.range);
+        column.valueType = {
+          name: column.range,
+          isTextType: isTextType(column.range),
+          isReferenceType: isReferenceType(column.range)
+        };
       }
 
       function resolveColumns() {
@@ -101,6 +117,7 @@ angular.module('groongaAdminApp')
             response.tables().forEach(function(table) {
               schema.tables[table.name] = table;
             });
+            resolveTables();
 
             var fetchColumnsTasks = [];
             angular.forEach(schema.tables, function(table) {
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index