Improve indexing for /editor/level and editor/thang

This commit is contained in:
Nick Winter 2015-11-03 09:32:59 -08:00
parent 3dae9aac88
commit c6bb5b5329
2 changed files with 5 additions and 0 deletions

View file

@ -166,6 +166,9 @@ module.exports = class Handler
res.end()
if term
filter.filter.$text = $search: term
else if filters.length is 1 and filters[0].filter?.index is true
# All we are doing is an empty text search, but that doesn't hit the index, so we'll just look for the slug.
filter.filter = slug: {$exists: true}
args = [filter.filter]
args.push projection if projection
q = @modelClass.find(args...)

View file

@ -21,6 +21,7 @@ LevelSchema.index(
'language_override': 'searchLanguage'
'textIndexVersion': 2
})
LevelSchema.index(
{
original: 1
@ -32,6 +33,7 @@ LevelSchema.index(
unique: true
})
LevelSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
LevelSchema.index({index: 1}, {name: 'index index', sparse: true}) # because we can't use the text search index with no term
LevelSchema.plugin(plugins.NamedPlugin)
LevelSchema.plugin(plugins.PermissionsPlugin)