综合资讯   

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

时间:2012-12-26 21:56:37

来自 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
}

 

来源:开源中国社区 [http://www.oschina.net]

Notice: Constant RUNTIME already defined in /srv/html/srccn/news/config.php on line 15 Notice: Constant ROOTDIR already defined in /srv/html/srccn/news/config.php on line 16 Notice: Constant SITEDIR already defined in /srv/html/srccn/news/config.php on line 17 Notice: Constant DATAURL already defined in /srv/html/srccn/news/config.php on line 20 Notice: Constant VERSION already defined in /srv/html/srccn/news/system/kernel.php on line 17 Notice: Constant COREDIR already defined in /srv/html/srccn/news/system/kernel.php on line 18 Fatal error: require(): Cannot redeclare class mysql in /srv/html/srccn/news/system/kernel.php on line 22