fullText is not working in Parse Server with Mlab [closed]

ⅰ亾dé卋堺 提交于 2019-12-13 03:41:32

问题


I am running parse server(2.8.4) on heroku with Mlab. I a trying to search based on word match but the fullText throwing an error,here is my query:

var query1 = new Parse.Query("SearchTerms");
query1.fullText("searchString", "programmer");

It throwing below error:

ParseError {
2019-11-24T03:01:42.421284+00:00 app[web.1]:   code: 1,
2019-11-24T03:01:42.421285+00:00 app[web.1]:   message: {
2019-11-24T03:01:42.421286+00:00 app[web.1]:     name: 'MongoError',
2019-11-24T03:01:42.421287+00:00 app[web.1]:     message: 'text index required for $text query',
2019-11-24T03:01:42.421288+00:00 app[web.1]:     ok: 0,
2019-11-24T03:01:42.421289+00:00 app[web.1]:     errmsg: 'text index required for $text query',
2019-11-24T03:01:42.421290+00:00 app[web.1]:     code: 27,
2019-11-24T03:01:42.421291+00:00 app[web.1]:     codeName: 'IndexNotFound',
2019-11-24T03:01:42.421292+00:00 app[web.1]:     operationTime: '6762703032942592018',
2019-11-24T03:01:42.421293+00:00 app[web.1]:     '$clusterTime': { clusterTime: '6762703032942592018', signature: [Object] }
2019-11-24T03:01:42.421294+00:00 app[web.1]:   }
2019-11-24T03:01:42.421295+00:00 app[web.1]: }

On Web I found below solution:

db.collection.createIndex(
   {
     field1: "text",
     field2: "text",
     etc...         
   }
)

But I don't know where to place this code.

Is there any way we can use this solution with mlab

INDEX ISSUE HAS BEEN RESOLVED by following a guide from @Suat

But new issue arrives: I am using 10 or query with fullText and getting this error:

    [31merror[39m: Error generating response. ParseError {
2019-11-25T08:46:46.632775+00:00 app[web.1]: code: 1,
2019-11-25T08:46:46.632776+00:00 app[web.1]: message: MongoError: Too many text expressions
2019-11-25T08:46:46.632778+00:00 app[web.1]: at queryCallback (/app/node_modules/mongodb-core/lib/cursor.js:247:25)
2019-11-25T08:46:46.632779+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/pool.js:531:18
2019-11-25T08:46:46.632781+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:75:11) {
2019-11-25T08:46:46.632783+00:00 app[web.1]: name: 'MongoError',
2019-11-25T08:46:46.632784+00:00 app[web.1]: message: 'Too many text expressions',
2019-11-25T08:46:46.632785+00:00 app[web.1]: ok: 0,
2019-11-25T08:46:46.632787+00:00 app[web.1]: errmsg: 'Too many text expressions',
2019-11-25T08:46:46.632788+00:00 app[web.1]: code: 2,
2019-11-25T08:46:46.632789+00:00 app[web.1]: codeName: 'BadValue',
2019-11-25T08:46:46.632791+00:00 app[web.1]: operationTime: Timestamp { bsontype: 'Timestamp', low: 6, high_: 1574671603 },
2019-11-25T08:46:46.632792+00:00 app[web.1]: '$clusterTime': { clusterTime: [Timestamp], signature: [Object] },
2019-11-25T08:46:46.632793+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2019-11-25T08:46:46.632794+00:00 app[web.1]: }

回答1:


Your question is mostly MongoDB and mLab specificed.

  1. Open your mLab dashboard
  2. Select your deployment
  3. Select your database
  4. Select your collection

In collection detail page there are Documents, Indexes, Stats, Tools on top of page.

Choose Indexes and click to 'Add Index' button there will be a popup screen which you can enter indexes like that

{
     "job": "text"      
}

and then click 'Create In Background' button. After a few seconds your index will be created and now you can use your fullText function.

But remember

Note: Full Text Search can be resource intensive. Ensure the cost of using indexes is worth the benefit, see storage requirements & performance costs of text indexes..



来源:https://stackoverflow.com/questions/59014852/fulltext-is-not-working-in-parse-server-with-mlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!