How to text index in mongodb using nodejs

I am trying to create a text index to implement text search in mongodb using nodejs.

Example:

db.collection("test").ensureIndex( { name: 'text', description: 'text' }, { weights: { name: 10, description: 20 }, name: 'test' }, function(err, data){ // here err is null, and data is "test" }); 

After that I try to get information about this index with the name "test", it gives me data such as

  { v: 1, key: { _fts: 'text', _ftsx: 1 }, ns: '53b3e49b31afd3d3354886b7_rajeshdemo.test', name: 'test', weights: { description: 1, name: 1 }, default_language: 'english', language_override: 'language', textIndexVersion: 1 } 

He does not accept weight information.

How to create a text search index in mongodb (version 2.6) using nodejs?

+5
source share
1 answer

I have found a solution.

I actually use the nodejs mongodb 1.4.5 driver. After upgrading to 1.4.9, it works fine.

0
source

Source: https://habr.com/ru/post/1209695/


All Articles