insert documents in MongoDB multiple nested elements - mongodb

I am looking to insert another document in a multiple nested document. Do you have any other ideas of how to solve it? Thanks
{
"_id" : ObjectId("576bddaa08b8f7dc20000033"),
"Name" : "Business",
"Image" : "fa fa-dollar",
"Description" : "Money, Capitalism, Business",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "https://www.rocklandtrust.com/assets/content/txh9vvwg/2014/08/06/business%20savings.jpg",
"Children" : [
{
"_id" : ObjectId("57715e0608b8f7441b00002d"),
"Name" : "Business School",
"URLName" : "Business-School",
"Image" : "http://www.small-business-website.net/wp-content/uploads/2016/04/How-to-achieve-a-successful-business-sale-128x128.jpg",
"Description" : "Everything about Business Schools",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://www.incae.edu/sites/default/files/styles/slideshow-un-medio/public/primerdiamba2010_018.jpg?itok=LfZmxw14",
"Children" : []
},
{
"_id" : ObjectId("57715f0d08b8f7942c00002b"),
"Name" : "Journals",
"URLName" : "Journals",
"Image" : "http://www.alliedacademies.org/images/accounting.png",
"Description" : "Journals and Diaries about Businesses",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://www.advantagebusinessvaluations.com/wp-content/uploads/2015/08/slide3.jpg",
"Children" : []
},
{
"_id" : ObjectId("57740ae208b8f7f41a000039"),
"Name" : "Stock Exchange",
"URLName" : "Stock-Exchange",
"Image" : "https://38.media.tumblr.com/avatar_bd29383b5657_128.png",
"Description" : "Stock Exchange, US Stock",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://c.fastcompany.net/multisite_files/coexist/imagecache/1280/poster/2013/04/1681873-poster-1280-stock-chart.jpg",
"Children" : [
{
"_id" : ObjectId("5774464608b8f7f41a00004a"),
"Name" : "Stock Software",
"URLName" : "Stock-Software",
"Image" : "http://s1.evcdn.com/images/block/I0-001/026/278/060-2.jpeg_/1-day-introduction-forex-stock-market-trading-60.jpeg",
"Description" : "Stock Excba ge Software",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://media.therakyatpost.com/wp-content/uploads/2015/04/stock-exchange-record-bigstock-900x470.jpg",
"Children" : []
},
{
"_id" : ObjectId("5774e2cb08b8f76c1a00002e"),
"Name" : "Meta Trader",
"URLName" : "Meta-Trader",
"Image" : "http://www.file-extensions.org/imgs/app-icon/128/6904/metatrader-icon.png",
"Description" : "MetaTrader",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://www.roboforex.com/files/filemanager/image/site/metatrader.png",
"Children" : []
},
{
"_id" : ObjectId("5774eb2708b8f76c1a000043"),
"Name" : "Meta Trader",
"URLName" : "Meta-Trader",
"Image" : "http://www.file-extensions.org/imgs/app-icon/128/6904/metatrader-icon.png",
"Description" : "MetaTrader",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://www.roboforex.com/files/filemanager/image/site/metatrader.png",
"Children" : []
},
{
"_id" : ObjectId("5774eb8208b8f76c1a000044"),
"Name" : "Meta Trader",
"URLName" : "Meta-Trader",
"Image" : "http://www.file-extensions.org/imgs/app-icon/128/6904/metatrader-icon.png",
"Description" : "MetaTrader",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://www.roboforex.com/files/filemanager/image/site/metatrader.png",
"Children" : []
},
{
"_id" : ObjectId("5774eb8f08b8f76c1a000045"),
"Name" : "Meta Trader",
"URLName" : "Meta-Trader",
"Image" : "http://www.file-extensions.org/imgs/app-icon/128/6904/metatrader-icon.png",
"Description" : "MetaTrader",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0,
"CoverImage" : "http://www.roboforex.com/files/filemanager/image/site/metatrader.png",
"Children" : []
}
]
}
],
"URLName" : "Business"
}
How can I insert another document in Business.Children.Children.(Stock Software).Children

Use the positional operator to push values.
https://docs.mongodb.com/manual/reference/operator/update/positional/
db.collectioname.update(
{
"_id" : ObjectId("576bddaa08b8f7dc20000033"),
"Children._id" : ObjectId("57715e0608b8f7441b00002d")
},
{
$push: {
"Children.$.Children": {
"Name" : "Business School",
"URLName" : "Business-School",
"Image" : "http://www.small-business-website.net/wp-content/uploads/2016/04/How-to-achieve-a-successful-business-sale-128x128.jpg",
"Description" : "Everything about Business Schools",
"NoForums" : 0,
"NoTopics" : 0,
"NoComments" : 0,
"NoUsers" : 0
}
}
}
)
Note : Beware Mongo does not not allow nested documents to update.It is a known issue. It allows only to a single level.
https://jira.mongodb.org/browse/SERVER-831

Related

Deleting an object inside another object in Mongodb and for GOlang

I wanna delete a specific object inside an object, My object:
{
"_id" : ObjectId("5f577f3cce031ee00f5e32c9"),
"UserId" : 0,
"firstname" : "user 1",
"lastname" : "user 1",
"finishedTrainings" : [
{
"itemId" : 3,
"validationScore" : 1,
"timestamps" : {
"createdat" : ISODate("2020-09-09T12:57:31.275Z"),
"createdby" : 0,
"updatedat" : ISODate("0001-01-01T00:00:00Z"),
"updatedby" : 0
},
"isValidated" : true
},
{
"itemId" : 0,
"validationScore" : 0.6666666666666666,
"timestamps" : {
"createdat" : ISODate("2020-09-09T12:59:04.268Z"),
"createdby" : 0,
"updatedat" : ISODate("0001-01-01T00:00:00Z"),
"updatedby" : 0
},
"isValidated" : true
}
],
"biography" : ""
}
and I wanna delete the finishedTraining(id=3),what would be the syntax in mongodb
//code output from mongo shell 4.2, windows10
//data set as given in problem statement
> db.userTraining.find().pretty();
{
"_id" : ObjectId("5f577f3cce031ee00f5e32c9"),
"UserId" : 0,
"firstname" : "user 1",
"lastname" : "user 1",
"finishedTrainings" : [
{
"itemId" : 3,
"validationScore" : 1,
"timestamps" : {
"createdat" : ISODate("2020-09-09T12:57:31.275Z"),
"createdby" : 0,
"updatedat" : ISODate("0001-01-01T00:00:00Z"),
"updatedby" : 0
},
"isValidated" : true
},
{
"itemId" : 0,
"validationScore" : 0.6666666666666666,
"timestamps" : {
"createdat" : ISODate("2020-09-09T12:59:04.268Z"),
"createdby" : 0,
"updatedat" : ISODate("0001-01-01T00:00:00Z"),
"updatedby" : 0
},
"isValidated" : true
}
],
"biography" : ""
}
//assuming objectID is unique for the document, you can query your own business field
> db.userTraining.update(
... {_id:ObjectId("5f577f3cce031ee00f5e32c9")},
... {$pull:{"finishedTrainings":{itemId:3}}},
... false,
... true
... );
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.userTraining.find().pretty();
{
"_id" : ObjectId("5f577f3cce031ee00f5e32c9"),
"UserId" : 0,
"firstname" : "user 1",
"lastname" : "user 1",
"finishedTrainings" : [
{
"itemId" : 0,
"validationScore" : 0.6666666666666666,
"timestamps" : {
"createdat" : ISODate("2020-09-09T12:59:04.268Z"),
"createdby" : 0,
"updatedat" : ISODate("0001-01-01T00:00:00Z"),
"updatedby" : 0
},
"isValidated" : true
}
],
"biography" : ""
}
>
//above id=3 is deleted object from the array, other document object remain intact by using "$pull" in the update statement

Mongo Query Issue - Query records from two different collections and merge/join into one single record

I have two collections and From my queries , I got records from these collections as ,
Collection_A :
Query :
db.getCollection('Collection_A').findOne({"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})
Record :
{
"pdf" : {
"engine" : "pdf",
"status" : "done",
"retry" : 3,
"limit" : 4500,
"stop_on_detection" : 0,
"file_type" : "*",
"file_limit_slot" : 60,
"start_time" : 1543225534.08531,
"end_time" : 1543225534.90477,
"detection" : true
}
}
Collection_B:
Query :
db.getCollection('Collection_B').find({"md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})
Record :
{
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" : []
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}
How to merge these both records from these collections using a single query ? In SQL , I have used join to get data from two different tables. Since Im not familiar much with mongo , Not sure how to achieve this ?
Expected Result :
{
"pdf" : {
"status" : "Completed",
"detection" : true,
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" : []
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}
}
Update :
Tried This query :
db.getCollection('Collection_A').aggregate( [ { $match: {"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"}}, { $lookup: {from: "Collection_B",localField: "meta.md5", foreignField: "md5", as: "pdf"}}, { $project: {"pdf.status":1,"pdf.detection":1,"_id":0}} ] )
But i'm getting this error from the robo mongo client
Failed to execute script.
Error:
Assert: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed
_getErrorWithCode#src/mongo/shell/utils.js:25:13
doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate#:1:355
#(shell):1:1
Error: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed :
_getErrorWithCode#src/mongo/shell/utils.js:25:13
doassert#src/mongo/shell/assert.js:16:14
assert.commandWorked#src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate#src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate#:1:355
#(shell):1:1

How to perform lookup in subdocument array of mongo collection

I have 2 collection named ServiceProvider and Parents.
ServiceProvider:
{
"_id" : ObjectId("57235dc9588aec3e318b4567"),
"ServiceProviderID" : 3,
"Title" : "test",
"PostedMessage" : "test",
"TotalComments" : 0,
"TotalShares" : 0,
"TotalThanks" : 0,
"AddedOn" : "2016-04-29",
"LastModifiedOn" : "2016-04-29",
"PostAttachment" : {
"ImagePath" : ""
},
"PostComments" : [
{
"_id" : "14619355772980176",
"UserID" : 3,
"CommentMessage" : "test",
"TotalThanks" : 0,
"AddedOn" : "2016-04-29",
"LastModifiedOn" : "2016-04-29",
"CommentAttachment" : {
"ImagePath" : ""
}
},
{
"_id" : "1461935582156657330",
"UserID" : 3,
"CommentMessage" : "123",
"TotalThanks" : 0,
"AddedOn" : "2016-04-29",
"LastModifiedOn" : "2016-04-29",
"CommentAttachment" : {
"ImagePath" : ""
}
},
{
"_id" : "14619892452027996767",
"UserID" : 3,
"CommentMessage" : "45",
"TotalThanks" : 0,
"AddedOn" : "2016-04-30",
"LastModifiedOn" : "2016-04-30",
"CommentAttachment" : {
"ImagePath" : ""
}
},
{
"_id" : "14619896331049580283",
"UserID" : 3,
"CommentMessage" : "46",
"TotalThanks" : 0,
"AddedOn" : "2016-04-30",
"LastModifiedOn" : "2016-04-30",
"CommentAttachment" : {
"ImagePath" : ""
}
}
],
"Subscriber" : [ ]
}
Parents:
{
"35" : {
"ID" : "133",
"UID" : "7Cv1y3kjutSWgvhtH1Lp9yEDOeiFR0aAbB77uTnEJCR3HSH0s6eC7rEt",
"Name" : "Ash Nan",
"ProfileImagePath" : null
},
"36" : {
"ID" : "134",
"UID" : "2BRcj3xBnNzse7YiudouwmYprilzjkbrC4Yk7v9gPBcs6eC7rEt",
"Name" : "Test 45",
"ProfileImagePath" : "Chrysanthemum_134_1450777239#SIZE#.jpg"
},
"37" : {
"ID" : "135",
"UID" : "BCMMdFjfO7WXzESWQ8Wlnge4gMQoumBxXyY99NIou5UzKrRgs6eC7rEt",
"Name" : "test 45",
"ProfileImagePath" : "Penguins_135_1450777743#SIZE#.jpg"
},
"38" : {
"ID" : "136",
"UID" : "HxFmh7T4balaAbB77UTEgJtrxXyY99zCUEYeaAbB77SF11rKv8ad9FS6Tss6eC7rEt",
"Name" : "test1 test1",
"ProfileImagePath" : null
},
}
How to perform lookup query on Postcomments subdocument with Parents collection?
I want Name field from Parents collection to be inserted in ServiceProvider Postcomments subdocument.
I want query to return following:
{
"_id" : ObjectId("57235dc9588aec3e318b4567"),
"ServiceProviderID" : 3,
"Title" : "test",
"PostedMessage" : "test",
"TotalComments" : 0,
"TotalShares" : 0,
"TotalThanks" : 0,
"AddedOn" : "2016-04-29",
"LastModifiedOn" : "2016-04-29",
"PostAttachment" : {
"ImagePath" : ""
},
"PostComments" : [
{
"_id" : "14619355772980176",
"UserID" : 3,
"UserName" : "Chinmay Kulkarni",
"CommentMessage" : "test",
"TotalThanks" : 0,
"AddedOn" : "2016-04-29",
"LastModifiedOn" : "2016-04-29",
"CommentAttachment" : {
"ImagePath" : ""
}
},
{
"_id" : "1461935582156657330",
"UserID" : 3,
"UserName" : "Chinmay Kulkarni",
"CommentMessage" : "123",
"TotalThanks" : 0,
"AddedOn" : "2016-04-29",
"LastModifiedOn" : "2016-04-29",
"CommentAttachment" : {
"ImagePath" : ""
}
},
{
"_id" : "14619892452027996767",
"UserID" : 3,
"UserName" : "Chinmay Kulkarni",
"CommentMessage" : "45",
"TotalThanks" : 0,
"AddedOn" : "2016-04-30",
"LastModifiedOn" : "2016-04-30",
"CommentAttachment" : {
"ImagePath" : ""
}
},
{
"_id" : "14619896331049580283",
"UserID" : 3,
"UserName" : "Chinmay Kulkarni",
"CommentMessage" : "46",
"TotalThanks" : 0,
"AddedOn" : "2016-04-30",
"LastModifiedOn" : "2016-04-30",
"CommentAttachment" : {
"ImagePath" : ""
}
}
],
"Subscriber" : [ ]
}
I refer to this link but didn't get through. Any help would be appreciated. Thanks!

Output of my high lockTime and high page_faults value also

we are using mongodb for our collections .
This is my stats of my development server .
My concerns are that there is high lockTime on my development server and also there are high page_faults value also .
Please tell me how can we resolve this ??
PRIMARY> db.serverStatus()
{
"host" : "ubsc-aio:27018",
"version" : "2.0.4",
"process" : "mongod",
"uptime" : 3278692,
"uptimeEstimate" : 3098346,
"localTime" : ISODate("2013-08-30T10:55:06.997Z"),
"globalLock" : {
"totalTime" : 3278692551767,
"lockTime" : 139516930214,
"ratio" : 0.0425526114483682,
"currentQueue" : {
"total" : 0,
"readers" : 0,
"writers" : 0
},
"activeClients" : {
"total" : 1,
"readers" : 1,
"writers" : 0
}
},
"mem" : {
"bits" : 64,
"resident" : 2009,
"virtual" : 23455,
"supported" : true,
"mapped" : 11420,
"mappedWithJournal" : 22840
},
"connections" : {
"current" : 162,
"available" : 7838
},
"extra_info" : {
"note" : "fields vary by platform",
"heap_usage_bytes" : 3645040,
"page_faults" : 4147570
},
"indexCounters" : {
"btree" : {
"accesses" : 902898,
"hits" : 901095,
"misses" : 1803,
"resets" : 0,
"missRatio" : 0.0019969033046922245
}
},
"backgroundFlushing" : {
"flushes" : 54639,
"total_ms" : 36709498,
"average_ms" : 671.8552316111203,
"last_ms" : 81,
"last_finished" : ISODate("2013-08-30T10:54:43.013Z")
},
"cursors" : {
"totalOpen" : 1,
"clientCursors_size" : 1,
"timedOut" : 7
},
"network" : {
"bytesIn" : 77779294441,
"bytesOut" : 314231714161,
"numRequests" : 189861092
},
"repl" : {
"setName" : "at",
"ismaster" : true,
"secondary" : false,
"hosts" : [
"localhost:27018",
"localhost:27017"
],
"arbiters" : [
"localhost:27019"
],
"primary" : "localhost:27018",
"me" : "localhost:27018"
},
"opcounters" : {
"insert" : 303294,
"query" : 133717078,
"update" : 59123588,
"delete" : 234256,
"getmore" : 48037783,
"command" : 125805489
},
"asserts" : {
"regular" : 0,
"warning" : 0,
"msg" : 0,
"user" : 16576,
"rollovers" : 0
},
"writeBacksQueued" : false,
"dur" : {
"commits" : 28,
"journaledMB" : 0.08192,
"writeToDataFilesMB" : 0.116123,
"compression" : 0.6743163821345669,
"commitsInWriteLock" : 0,
"earlyCommits" : 0,
"timeMs" : {
"dt" : 3000,
"prepLogBuffer" : 0,
"writeToJournal" : 25,
"writeToDataFiles" : 2,
"remapPrivateView" : 1
}
},
"ok" : 1
}

Why Using GeohayStack fail

I run this query in mongo shell, and successful get result
db.tablebusiness.find({ "LongitudeLatitude" : { "$near" : [106.772835, -6.186753], "$maxDistance" : 0.053980478460939611 }, "indexContents" : { "$all" : [/^warung/] } }).limit(2);
I got:
{
"_id" : "warung-nasi-nur-karomah__-6.19_106.78",
"BuildingID" : null,
"Title" : "Warung Nasi Nur Karomah",
"InBuildingAddress" : null,
"Building" : null,
"Street" : "Jl. Arjuna Utara No.35",
"Districts" : [],
"City" : "Jakarta",
"Country" : "Indonesia",
"LongitudeLatitudeFromGoogle" : null,
"DistanceFromGoogleAddress" : 0.0,
"Checkin" : 0,
"Note" : null,
"PeopleCount" : 0,
"Prominent" : 45.5,
"CountViews" : 0,
"StreetAdditional" : null,
"LongitudeLatitude" : {
"Longitude" : 106.775693893433,
"Latitude" : -6.18759540055471
},
"Rating" : {
"Stars" : 0.0,
"Weight" : 0.0
},
"Reviews" : [],
"ZIP" : null,
"Tags" : ["Restaurant"],
"Phones" : ["081380087011"],
"Website" : null,
"Email" : null,
"Price" : null,
"openingHour" : null,
"Promotions" : [],
"SomethingWrong" : false,
"BizMenus" : [],
"Brochures" : [],
"Aliases" : [],
"indexContents" : ["restaura", "estauran", "staurant", "taurant", "aurant", "urant", "rant", "ant", "nt", "t", "warung", "arung", "rung", "ung", "ng", "g", "nasi", "asi", "si", "i", "nur", "ur", "r", "karomah", "aromah", "romah", "omah", "mah", "ah", "h"]
}
But when I try this query with additional search multikey index I got nothing result
db.runCommand({ geoSearch : "tablebusiness", near : [106.772835, -6.186753], maxDistance : 0.053980478460939611, search : { "indexContents" : { "$all" : [/^warung/] } }, limit : 30 })
I got this
{
"results" : [ ],
"stats" : {
"time" : 0,
"btreeMatches" : 0,
"n" : 0
},
"ok" : 1
}
This is index in my collection database
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"LongitudeLatitude" : "2d",
"Prominent" : -1,
"indexContents" : 1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "LongLat_Prominent_indexContents",
"dropDups" : false,
"background" : false
},
{
"v" : 1,
"key" : {
"LongitudeLatitude" : "2d",
"Prominent" : -1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "LongLat_Prominent",
"dropDups" : false,
"background" : false
},
{
"v" : 1,
"key" : {
"indexContents" : 1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "indexContents",
"dropDups" : false,
"background" : false
},
{
"v" : 1,
"key" : {
"LongitudeLatitude" : "2d",
"indexContents" : 1,
"Prominent" : -1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "LongitudeLatitude__indexContents_1_Prominent_-1",
"bits" : 22
},
{
"v" : 1,
"key" : {
"Title" : 1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "Title",
"dropDups" : false,
"background" : false
},
{
"v" : 1,
"key" : {
"City" : 1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "City",
"dropDups" : false,
"background" : false
},
{
"v" : 1,
"key" : {
"LongitudeLatitude" : "geoHaystack",
"indexContents" : 1
},
"ns" : "isikotacobacoba.tablebusiness",
"name" : "LongitudeLatitude__indexContents_1",
"bucketSize" : 0.1
}
]
How format use runCommand mongoDB using geohaystack with additional field mulikey??
Geohaystack queries do not support arrays for the additional field,
only single values. The current implementation of geospatial indexes
and geohaystacks do not use the standard query and index code.
The examples from MongoDB's geohaystack documentation (
http://www.mongodb.org/display/DOCS/Geospatial+Haystack+Indexing )
only shows the additional field to be a simple single value, not an
array of values in a geohaystack query.