Navigation Menu

Skip to content

Commit

Permalink
Accept index field options via the configurations API
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 13, 2012
1 parent d4eafd0 commit d3956d0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
30 changes: 28 additions & 2 deletions lib/api/2011-02-01/configuration.js
Expand Up @@ -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,
Expand Down
20 changes: 14 additions & 6 deletions lib/database/index-field.js
Expand Up @@ -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
Expand Down

0 comments on commit d3956d0

Please sign in to comment.