-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathRangeQuery.cs
46 lines (44 loc) · 1.41 KB
/
RangeQuery.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// start-enable-range
var encryptedFields = new BsonDocument
{
{
"fields", new BsonArray
{
new BsonDocument
{
{ "keyId", BsonNull.Value },
{ "path", "patientRecord.ssn" },
{ "bsonType", "string" },
{ "queries", new BsonDocument("queryType", "equality") }
},
new BsonDocument
{
{ "keyId", BsonNull.Value },
{ "path", "patientRecord.billing" },
{ "bsonType", "object" }
},
new BsonDocument
{
{ "keyId", BsonNull.Value },
{ "path", "patientRecord.billAmount" },
{ "bsonType", "int" },
{ "queries", new BsonDocument
{
{ "queryType", "range" },
{ "sparsity", 1 },
{ "min", 100 },
{ "max", 2000 },
{ "trimFactor", 4 }
}
},
}
}
}
};
// end-enable-range
// start-query-range
var filter = Builders<Patient>.Filter.Gt("patientRecord.billAmount", 1000) &
Builders<Patient>.Filter.Lt("patientRecord.billAmount", 2000);
var findResult = encryptedCollection.Find(filter).FirstOrDefault();
Console.WriteLine(findResult.ToJson());
// end-query-range