{"id":13408482,"url":"https://github.com/mongoosejs/mongoose-text-search","last_synced_at":"2025-06-20T12:10:22.420Z","repository":{"id":7654156,"uuid":"9015137","full_name":"mongoosejs/mongoose-text-search","owner":"mongoosejs","description":"MongoDB 2.4 text search support for mongoose","archived":false,"fork":false,"pushed_at":"2013-11-07T05:28:01.000Z","size":111,"stargazers_count":154,"open_issues_count":6,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-20T01:51:23.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongoosejs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-25T20:22:03.000Z","updated_at":"2024-07-21T17:04:08.000Z","dependencies_parsed_at":"2022-09-09T17:13:32.323Z","dependency_job_id":null,"html_url":"https://github.com/mongoosejs/mongoose-text-search","commit_stats":null,"previous_names":["aheckmann/mongoose-text-search"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mongoosejs/mongoose-text-search","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-text-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-text-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-text-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-text-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongoosejs","download_url":"https://codeload.github.com/mongoosejs/mongoose-text-search/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoosejs%2Fmongoose-text-search/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260863780,"owners_count":23074285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:00:53.131Z","updated_at":"2025-06-20T12:10:17.403Z","avatar_url":"https://github.com/mongoosejs.png","language":"JavaScript","funding_links":[],"categories":["Database"],"sub_categories":["Mongo DB"],"readme":"#mongoose-text-search\n======================\n\nProvides MongoDB 2.4 text search support for mongoose.\n\n[![Build Status](https://travis-ci.org/aheckmann/mongoose-text-search.png?branch=master)](https://travis-ci.org/aheckmann/mongoose-text-search)\n\n## Example:\n\n```js\n// modules\nvar mongoose = require('mongoose');\nvar textSearch = require('mongoose-text-search');\n\n// create our schema\nvar gameSchema = mongoose.Schema({\n    name: String\n  , tags: [String]\n  , likes: Number\n  , created: Date\n});\n\n// give our schema text search capabilities\ngameSchema.plugin(textSearch);\n\n// add a text index to the tags array\ngameSchema.index({ tags: 'text' });\n\n// test it out\nvar Game = mongoose.model('Game', gameSchema);\n\nGame.create({ name: 'Super Mario 64', tags: ['nintendo', 'mario', '3d'] }, function (err) {\n  if (err) return handleError(err);\n\n  Game.textSearch('3d', function (err, output) {\n    if (err) return handleError(err);\n\n    var inspect = require('util').inspect;\n    console.log(inspect(output, { depth: null }));\n\n    // { queryDebugString: '3d||||||',\n    //   language: 'english',\n    //   results:\n    //    [ { score: 1,\n    //        obj:\n    //         { name: 'Super Mario 64',\n    //           _id: 5150993001900a0000000001,\n    //           __v: 0,\n    //           tags: [ 'nintendo', 'mario', '3d' ] } } ],\n    //   stats:\n    //    { nscanned: 1,\n    //      nscannedObjects: 0,\n    //      n: 1,\n    //      nfound: 1,\n    //      timeMicros: 77 },\n    //   ok: 1 }\n  });\n});\n```\n\n### Output:\n\nThe output is not limited to the found documents themselves but also the complete details of the executed command.\n\nThe `results` property of the output is an array of objects containing the found document and its corresponding search ranking. `score` is the ranking, `obj` is the [mongoose document](http://mongoosejs.com/docs/documents.html).\n\nFor more information about these properties, read the [MongoDB documentation](http://docs.mongodb.org/manual/reference/text-search/#text-search-output).\n\n## Options\n\n`mongoose-text-search` supports passing an options object as the second argument.\n\n- `project`: select which [fields](http://docs.mongodb.org/manual/reference/command/text/) to return (mongoose [field selection](http://mongoosejs.com/docs/api.html#query_Query-select) syntax supported)\n- `filter`: declare an additional [query matcher](http://docs.mongodb.org/manual/reference/command/text/) using `find` syntax (arguments are cast according to the schema).\n- `limit`: [maximum number](http://docs.mongodb.org/manual/reference/command/text/) of documents (mongodb default is 100)\n- `language`: change the [search language](http://docs.mongodb.org/manual/reference/command/text/)\n- `lean`: Boolean: if true, documents are not cast to [mongoose documents](http://mongoosejs.com/docs/documents.html) (default false)\n\nExample:\n\n```js\nvar options = {\n    project: '-created'                // do not include the `created` property\n  , filter: { likes: { $gt: 1000000 }} // casts queries based on schema\n  , limit: 10\n  , language: 'spanish'\n  , lean: true\n}\n\nGame.textSearch('game -mario', options, callback);\n```\n\n## Notes:\n\nAs of mongoose 3.6.0, text indexes may be added using the [Schema.index()](http://mongoosejs.com/docs/api.html#schema_Schema-index) method.\n\nAs of MongoDB 2.4.0, [text search](http://docs.mongodb.org/manual/applications/text-search/) is experimental/beta. As such, this functionality is not in mongoose core.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-text-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongoosejs%2Fmongoose-text-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoosejs%2Fmongoose-text-search/lists"}