Migrated from mongoose-text-search to new built-in operators. Fixed #2367.

This commit is contained in:
Nick Winter 2015-02-21 14:22:43 -08:00
parent 40ff7d4116
commit 498eae328a
4 changed files with 11 additions and 16 deletions

View file

@ -45,7 +45,6 @@
"moment": "~2.5.0",
"mongodb": "1.2.x",
"mongoose": "3.8.x",
"mongoose-text-search": "~0.0.2",
"request": "2.12.x",
"tv4": "~1.0.16",
"lodash": "~2.4.1",

View file

@ -27,7 +27,7 @@ whenAllFinished = ->
async.parallel [
# Misc
#(c) -> report UserHandler.recalculateStats, 'gamesCompleted', c
(c) -> report UserHandler.recalculateStats, 'gamesCompleted', c
# Edits
(c) -> report UserHandler.recalculateStats, 'articleEdits', c

View file

@ -164,19 +164,17 @@ module.exports = class Handler
res.send matchedObjects
res.end()
if term
filter.project = projection
@modelClass.textSearch term, filter, callback
filter.filter.$text = $search: term
args = [filter.filter]
args.push projection if projection
q = @modelClass.find(args...)
if skip? and skip < 1000000
q.skip(skip)
if limit? and limit < FETCH_LIMIT
q.limit(limit)
else
args = [filter.filter]
args.push projection if projection
q = @modelClass.find(args...)
if skip? and skip < 1000000
q.skip(skip)
if limit? and limit < FETCH_LIMIT
q.limit(limit)
else
q.limit(FETCH_LIMIT)
q.exec callback
q.limit(FETCH_LIMIT)
q.exec callback
# if it's not a text search but the user is an admin, let him try stuff anyway
else if req.user?.isAdmin()
# admins can send any sort of query down the wire

View file

@ -1,5 +1,4 @@
mongoose = require('mongoose')
textSearch = require('mongoose-text-search')
log = require 'winston'
utils = require '../lib/utils'
@ -293,7 +292,6 @@ module.exports.SearchablePlugin = (schema, options) ->
index[prop] = 'text' for prop in searchable
# should now have something like {'index': 1, name: 'text', body: 'text'}
schema.plugin(textSearch)
schema.index(index, {sparse: true, name: 'search index', language_override: 'searchLanguage'})
schema.pre 'save', (next) ->