SHIMODA Hiroshi
null+****@clear*****
Mon Aug 13 17:09:33 JST 2012
SHIMODA Hiroshi 2012-08-13 17:09:33 +0900 (Mon, 13 Aug 2012) New Revision: d3956d099634ec9b921848db9207abdbe7a5bc63 https://github.com/groonga/gcs/commit/d3956d099634ec9b921848db9207abdbe7a5bc63 Log: Accept index field options via the configurations API Modified files: lib/api/2011-02-01/configuration.js lib/database/index-field.js Modified: lib/api/2011-02-01/configuration.js (+28 -2) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-08-13 17:00:35 +0900 (13f9e1d) +++ lib/api/2011-02-01/configuration.js 2012-08-13 17:09:33 +0900 (e74a1ae) @@ -236,8 +236,34 @@ handlers.DefineIndexField = function(context, request, response) { var createdAt = new Date(); try { - field.type = fieldType; - field.createSync(); + var facetEnabled = fieldType == 'text' ? + request.query['TextOptions.FacetEnabled'] : + fieldType == 'literal' ? + request.query['LiteralOptions.FacetEnabled'] : + null ; + if (facetEnabled !== null) + field.facetEnabled = facetEnabled; + + var resultEnabled = fieldType == 'text' ? + request.query['TextOptions.ResultEnabled'] : + fieldType == 'literal' ? + request.query['LiteralOptions.ResultEnabled'] : + null ; + if (resultEnabled !== null) + field.resultEnabled = resultEnabled; + + var searchEnabled = fieldType == 'literal' ? + request.query['LiteralOptions.SearchEnabled'] : + null ; + if (searchEnabled !== null) + field.searchEnabled = searchEnabled; + + if (!field.exists()) { + field.type = fieldType; + field.createSync(); + } else { + field.saveOptionsSync(); + } response.contentType('application/xml'); response.send(createDefineIndexFieldResponse({ field: field, Modified: lib/database/index-field.js (+14 -6) =================================================================== --- lib/database/index-field.js 2012-08-13 17:00:35 +0900 (e0cf55f) +++ lib/database/index-field.js 2012-08-13 17:09:33 +0900 (a8d1977) @@ -258,15 +258,23 @@ IndexField.prototype = { source: this.columnName }); - if (this.facetEnabled !== undefined) + this.saveOptionsSync(); + }, + saveOptionsSync: function() { + this.facetEnabled; + if (this._facetEnabled !== undefined) this.domain.setConfiguration(this.facetEnabledConfigurationKey, - this.facetEnabled); - if (this.resultEnabled !== undefined) + this._facetEnabled); + + this.resultEnabled; + if (this._resultEnabled !== undefined) this.domain.setConfiguration(this.resultEnabledConfigurationKey, - this.resultEnabled); - if (this.searchEnabled !== undefined) + this._resultEnabled); + + this.searchEnabled; + if (this._searchEnabled !== undefined) this.domain.setConfiguration(this.searchEnabledConfigurationKey, - this.searchEnabled); + this._searchEnabled); }, deleteSync: function() { // backup information for re-creation -------------- next part -------------- HTML����������������������������...Download