760176104 发表于 2015-7-10 10:20:21

MongoDB 核心将支持全文搜索功能 (2.3.2)

  来自 MongoDB 官方 JIRA 的一个新特性报告称 MongoDB 将在 2.3.2 版本中增加全文搜索功能。该功能还是体验到阶段,使用方法包括:
  db.adminCommand( { setParameter : "*", textSearchEnabled : true } );
  或者是:
  ./mongod --setParameter textSearchEnabled=true
  特性:

[*]parsing + stemming for latin languages
[*]multi-word scoring
[*]phrase matching
[*]word negation
[*]weights per field
[*]additional suffix index fields for coverings
[*]additional prefix index fields for partitioning
[*]specify language per document
  简单使用示例:


> db.foo.insert( { _id: 1 , desc: "the dog is running" } )
> db.foo.insert( { _id: 2 , desc: "the cat is walking" } )
> db.foo.ensureIndex( { "desc": "text" } )
> db.foo.runCommand( "text", { search : "walk" } )
{
    "queryDebugString" : "walk||||||",
    "language" : "english",
    "results" : [
      {
            "score" : 0.75,
            "obj" : {
                "_id" : 2,
                "desc" : "the cat is walking"
            }
      }
    ],
    "stats" : {
      "nscanned" : 1,
      "nscannedObjects" : 0,
      "n" : 1,
      "timeMicros" : 330
    },
    "ok" : 1
}
页: [1]
查看完整版本: MongoDB 核心将支持全文搜索功能 (2.3.2)