Commit 5a0caa54599df9d8572d473bb86ba1beda45e35e

Authored by Amrita Vishnoi
1 parent e6096b24

Query is optimized

400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs
... ... @@ -19,21 +19,14 @@ namespace AIAHTML5.API.Models
19 19  
20 20 var col = db.GetCollection<BsonDocument>("DAImages");
21 21  
22   - var pipeline = new BsonDocument[]
23   - {
24   - new BsonDocument{ {"$match", new BsonDocument("terms.SystemNumbers", Convert.ToInt32(systemNumber)) }},
25   - new BsonDocument{{"$unwind", "$terms"}},
26   - new BsonDocument{ { "$match", new BsonDocument("terms.SystemNumbers", Convert.ToInt32(systemNumber)) }},
27   - new BsonDocument{ { "$match", new BsonDocument("bodyViewIndex", Convert.ToInt32(bodyViewIndex)) }},
28   - new BsonDocument{ { "$match", new BsonDocument("layerNumber", Convert.ToInt32(layerNumber)) }},
29   - new BsonDocument{ { "$match", new BsonDocument("zoom", Convert.ToInt32(zoom)) }},
30   -
31   - new BsonDocument { {"$project", new BsonDocument()
32   - .Add("_id", 0)
33   - .Add("terms", 1)
34   - .Add("bodyRegionId", 1)
35   - .Add("layerNumber", 1)
36   - .Add("bodyViewIndex", 1)
  22 + var pipeline = new BsonDocument[]
  23 + {
  24 + new BsonDocument{{"$unwind", "$terms"}},
  25 + new BsonDocument{ { "$match", new BsonDocument("terms.SystemNumbers", Convert.ToInt32(systemNumber)).Add("bodyViewIndex", Convert.ToInt32(bodyViewIndex)).Add("layerNumber", Convert.ToInt32(layerNumber)).Add("zoom", Convert.ToInt32(zoom)) }},
  26 + new BsonDocument { {"$project", new BsonDocument()
  27 + .Add("_id", 0)
  28 + .Add("terms", 1)
  29 + .Add("bodyRegionId", 1)
37 30 } }
38 31 };
39 32  
... ...