mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Improve indexing for /editor/level and editor/thang
This commit is contained in:
parent
3dae9aac88
commit
c6bb5b5329
2 changed files with 5 additions and 0 deletions
|
@ -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...)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue