Friday, February 27, 2015

Mongo db

Connecting to MongoDB
D:\tools\mongodb\bin>mongo 10.40.1.77:27017
MongoDB shell version: 2.2.2
connecting to: 10.40.1.77:27017/test
mongos>
mongos>
mongos> sh.status();
--- Sharding Status ---
  sharding version: { "_id" : 1, "version" : 3 }
  shards:
        {  "_id" : "PPSHRD01",  "host" : "PPSHRD01:10001" }
        {  "_id" : "PPSHRD02",  "host" : "PPSHRD02:10002" }
  databases:
        {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
        {  "_id" : "test",  "partitioned" : true,  "primary" : "PPSHRD01" }
        {  "_id" : "mktpdm",  "partitioned" : true,  "primary" : "PPSHRD02" }
        {  "_id" : "*",  "partitioned" : false,  "primary" : "PPSHRD01" }

Start
D:\mongo\bin>mongod --dbpath=D:\mongo\bin\data\db
Import
mongoimport --db test --collection gtin --type csv --file c:/poc.csv --fields item_sync_fact_id,sync_status,sync_cnt,unique_syncnt,frmcount,frmstatus,frmorgname,frmglobal,tocount,tostatus,torogname,toglobal,day,month,itemname,desc,brickcd,clscd

D:\mongo\bin>mongoimport --db test --collection gtin --type csv --file d:/mongo/
pocbck.csv --fields item_sync_fact_id,sync_status,sync_cnt,unique_syncnt,frmcoun
t,frmstatus,frmorgname,frmglobal,tocount,tostatus,torogname,toglobal,day,month,i
temname,desc,brickcd,clscd
connected to: 127.0.0.1
imported 17430 objects

query

{
collectionName : 'gtin',
sort:{frmcount':1},

}


 emails.update({"solrid" : mongoid},{"$set": {"project":prtag, "customer":cutag,"phase":phtag,"topic":toptag,"importance":imtag,"expert":extag,"notes":notes,"tagged":'Y'}})

To go to mongo console


./mongo 172.23.2.5:27017