<commit_before>var mongoose = require('mongoose'),
    mongoosastic = require('mongoosastic');
var Schema = mongoose.Schema,
    ObjectId = Schema.ObjectId;

var UserSchema = exports.UserSchema = new Schema({
    id: String,
    displayName: String
});

// index users
UserSchema.plugin(mongoosastic, {index: 'requirements-editor'});

var User = mongoose.model('User', UserSchema);

var RequirementSchema = new Schema({
    author: ObjectId,
    version: Number,
    title: String,
    children: {},
    auth_read: [String],
    auth_write: [String],
    auth_admin: [String]
});

var Requirement = mongoose.model('Requirement', RequirementSchema);

var ResultSchema = new Schema({
    name: String,
    requirement: String,
    testbench_manifests: {},
    auth_read: [String],
    auth_write: [String],
    auth_admin: [String]
});

var Result = mongoose.model('Result', ResultSchema);

// index requirements
// TODO: index nested document
//RequirementSchema.plugin(mongoosastic, {index: 'requirements-editor'});
<commit_msg>Fix nested schema indexing.<commit_after>var mongoose = require('mongoose'),
    mongoosastic = require('mongoosastic');
var Schema = mongoose.Schema,
    ObjectId = Schema.ObjectId;

var UserSchema = exports.UserSchema = new Schema({
    id: String,
    displayName: String
});

// index users
UserSchema.plugin(mongoosastic, {index: 'requirements-editor'});

var User = mongoose.model('User', UserSchema);

var RequirementSchema = new Schema({
    author: {type: ObjectId},
    version: Number,
    title: String,
    children: {},
    auth_read: [String],
    auth_write: [String],
    auth_admin: [String]
});

// index requirements
RequirementSchema.plugin(mongoosastic, {index: 'requirements-editor'});

var Requirement = mongoose.model('Requirement', RequirementSchema);

var ResultSchema = new Schema({
    name: String,
    requirement: String,
    testbench_manifests: {},
    auth_read: [String],
    auth_write: [String],
    auth_admin: [String]
});

// index results
ResultSchema.plugin(mongoosastic, {index: 'requirements-editor'});

var Result = mongoose.model('Result', ResultSchema);

{'fraction_non_alphanumeric': 0.13615023474178403, 'fraction_numerical': 0.0, 'mean_word_length': 4.492268041237113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6772624', 'n_tokens_mistral': 648, 'n_tokens_neox': 658, 'n_words': 159}