0
嗨進出口新的蒙戈DB,並試圖開始使用它DateTime類型MongoDB的搜索,我創建了一個收集和插入這個文件到它通過不工作
{
"_id" : ObjectId("574ad7c42368e58f8c07a47d"),
"id" : 10000,
"BookieId" : 1,
"EventBookieId" : null,
"LeagueId" : 214,
"LeagueNameId" : 4571,
"Team1Id" : 435,
"Team1NameId" : null,
"Team2Id" : 430,
"Team2NameId" : null,
"EventDateTime" : "2013-09-14T14:00:00",
"isNew" : true,
"CountryId" : 36,
"isCountry" : true,
"isLeague" : true,
"Gameid" : null,
"Reversed" : false,
"eventId" : 10000,
"bets" : [
{
"id" : 1,
"EventConnectionId" : 10000,
"isCorners" : false,
"DateTime" : "2013-09-10T09:06:43.333",
"IsLive" : false,
"Team1Score" : null,
"Team2Score" : null,
"Team1RedCards" : null,
"Team2RedCards" : null,
"odds" : []
},
{
"id" : 2,
"EventConnectionId" : 10000,
"isCorners" : false,
"DateTime" : "2013-09-10T19:50:26.84",
"IsLive" : false,
"Team1Score" : 0,
"Team2Score" : 0,
"Team1RedCards" : null,
"Team2RedCards" : null,
"odds" : [
{
"id" : 62282718,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "21968173",
"ScrapingDateTime" : "2013-09-13T08:39:15.81",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 1.81,
"Odds2" : 2.1236,
"Odds3" : null,
"MaxBet" : 2000,
"Bet" : "Hcap",
"BetGamePart" : 0,
"Line" : -0.25,
"ID_IDENTITY" : 1
},
{
"id" : 62282719,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "21968175",
"ScrapingDateTime" : "2013-09-13T08:39:15.81",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.04167,
"Odds2" : 1.86,
"Odds3" : null,
"MaxBet" : 2000,
"Bet" : "Total",
"BetGamePart" : 0,
"Line" : 2.0,
"ID_IDENTITY" : 2
},
{
"id" : 62282720,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "21968177",
"ScrapingDateTime" : "2013-09-13T08:39:15.81",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.16,
"Odds2" : 3.45,
"Odds3" : 3.05,
"MaxBet" : 1000,
"Bet" : "X12",
"BetGamePart" : 0,
"Line" : null,
"ID_IDENTITY" : 3
},
{
"id" : 62282721,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "21968179",
"ScrapingDateTime" : "2013-09-13T08:39:15.81",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.21951,
"Odds2" : 1.7,
"Odds3" : null,
"MaxBet" : 1000,
"Bet" : "Hcap",
"BetGamePart" : 1,
"Line" : -0.25,
"ID_IDENTITY" : 4
},
{
"id" : 62282722,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "21968180",
"ScrapingDateTime" : "2013-09-13T08:39:15.81",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.78,
"Odds2" : 3.9,
"Odds3" : 1.99,
"MaxBet" : 500,
"Bet" : "X12",
"BetGamePart" : 1,
"Line" : null,
"ID_IDENTITY" : 5
},
{
"id" : 62282723,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "21968181",
"ScrapingDateTime" : "2013-09-13T08:39:15.81",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 1.93,
"Odds2" : 1.95,
"Odds3" : null,
"MaxBet" : 1000,
"Bet" : "Total",
"BetGamePart" : 1,
"Line" : 0.75,
"ID_IDENTITY" : 6
},
{
"id" : 62290838,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "14382209",
"ScrapingDateTime" : "2013-09-13T15:38:11.303",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 1.81,
"Odds2" : 2.1236,
"Odds3" : null,
"MaxBet" : 2000,
"Bet" : "Hcap",
"BetGamePart" : 0,
"Line" : -0.25,
"ID_IDENTITY" : 7
},
{
"id" : 62290839,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "14382211",
"ScrapingDateTime" : "2013-09-13T09:27:39.6",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.05263,
"Odds2" : 1.85,
"Odds3" : null,
"MaxBet" : 2000,
"Bet" : "Total",
"BetGamePart" : 0,
"Line" : 2.0,
"ID_IDENTITY" : 8
},
{
"id" : 62290840,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "14382213",
"ScrapingDateTime" : "2013-09-13T10:29:22.863",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.15,
"Odds2" : 3.45,
"Odds3" : 3.1,
"MaxBet" : 1000,
"Bet" : "X12",
"BetGamePart" : 0,
"Line" : null,
"ID_IDENTITY" : 9
},
{
"id" : 62290841,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "14382215",
"ScrapingDateTime" : "2013-09-13T15:38:11.303",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.21951,
"Odds2" : 1.7,
"Odds3" : null,
"MaxBet" : 1000,
"Bet" : "Hcap",
"BetGamePart" : 1,
"Line" : -0.25,
"ID_IDENTITY" : 10
},
{
"id" : 62290842,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "14382216",
"ScrapingDateTime" : "2013-09-13T15:38:11.303",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.78,
"Odds2" : 3.9,
"Odds3" : 1.99,
"MaxBet" : 500,
"Bet" : "X12",
"BetGamePart" : 1,
"Line" : null,
"ID_IDENTITY" : 11
},
{
"id" : 62290843,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "14382217",
"ScrapingDateTime" : "2013-09-13T15:38:11.303",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 1.93,
"Odds2" : 1.95,
"Odds3" : null,
"MaxBet" : 1000,
"Bet" : "Total",
"BetGamePart" : 1,
"Line" : 0.75,
"ID_IDENTITY" : 12
},
{
"id" : 62381139,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "20864356",
"ScrapingDateTime" : "2013-09-13T15:38:11.303",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.05263,
"Odds2" : 1.85,
"Odds3" : null,
"MaxBet" : 2000,
"Bet" : "Total",
"BetGamePart" : 0,
"Line" : 2.0,
"ID_IDENTITY" : 13
},
{
"id" : 62381140,
"BetId" : 2,
"BookieId" : 1,
"BookieBetId" : "20864358",
"ScrapingDateTime" : "2013-09-13T15:38:11.303",
"MinuteInGame" : null,
"GamePart" : null,
"Odds1" : 2.15,
"Odds2" : 3.45,
"Odds3" : 3.1,
"MaxBet" : 1000,
"Bet" : "X12",
"BetGamePart" : 0,
"Line" : null,
"ID_IDENTITY" : 14
}
]
}
]
}
現在我想按日期與此查詢
db.EventsBetsOdds.find({ "bets": { $elemMatch: { "DataTime": "2013-09-10T09:06:43.333" } } });
擷取的0結果在400毫秒 發現是我得到的,我在做什麼錯?
我試圖把一個索引此字段,索引完成
感謝!如果我想使用$ GTE這個值?我試圖將$ elemMatch更改爲$ gte並出現錯誤 –
AFAIK此字段應該是一個'ISODate'類型,以便使用'$ gte'運算符進行查詢。 – felipsmartins