Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapping: property with ObjectId type will neglect other es_ properties #130

Closed
b96705008 opened this issue Oct 23, 2014 · 2 comments
Closed

Comments

@b96705008
Copy link

For example, I have a schema, and it has user property, like:
user: {
type: Schema.Types.ObjectId,
ref: 'User',
es_indexed: true,
es_type: 'string',
es_index_analyzer: 'keyword',
es_cast: function(value){
if (value._id) {
return value.id;
} else {
return value.toString();
}
}
}

Because I don't want to analyze the user property, and add es_index_analyzer: 'keyword', but I found out that when mongoosastic meet ObjectId type, it will neglect other es_ setting, and that may not meet my need.

@b96705008
Copy link
Author

I find in mapping-generator.js

for line 55 -> 73, there shouldn't has continue in if
// If it is a objectid make it a string.
if(value.type === 'objectid'){
mapping[field].type = 'string';
continue;
}

//If indexing a number, and no es_type specified, default to double
if (value.type === 'number' && value['es_type'] === undefined) {
  mapping[field].type = 'double';
  continue;
}

// Else, it has a type and we want to map that!
for (var prop in value) {
  // Map to field if it's an Elasticsearch option
  if (prop.indexOf('es_') === 0 && prop !== 'es_indexed') {
    mapping[field][prop.replace(/^es_/, '')] = value[prop];
  }
}

@taterbase
Copy link
Owner

This issue has been moved to mongoosastic#12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants