Answer the question
In order to leave comments, you need to log in
Mongodb - multi-criteria search
We need advice from those who worked with MongoDB:
Let's say we have data like this:
{
a: {
id:1,
id2:3
},
b: [ "str1", "str2", "str3" ],
c: [
{f:"UA", g:12, s:"some string"},
{f:"RU", g:1, s:"some string2"}
],
d: [
{f:"UA", g:2, s:"some string3"},
{f:"UA", g:2, s:"some string4"}
],
dtF: ISODate("2012-04-25T21:00:00Z"),
dtT: ISODate("2012-04-28T21:00:00Z"),
cc: true,
m: 0,
v: 32,
...
}
{ "c.f" : "UA" , "d.f" : "UA" , "c.s":{"$regex":"some", "$options" : ""}}
{ "c.f" : "UA" , "d.f" : "UA" , "c.g" : { "$in" : [ 17]}, "b":{"$nin":["str1"]}
{ "m" : { "$gte" : 2 , "$lte" : 7} , "v" : { "$lte" : 50} , "c.f" : "UA" , "d.f" : "UA" , "c.g" : { "$in" : [ 27]}}
{"m" : { "$lte":20} , "v" : { "$lte" : 8},"c.f":"UA","c.g":{"$in":[1,12,16]}, "c.s":{"$regex":"some", "$options" : ""},"d.f":"RU","d.g":{"$in":[25,16]}, "d.s":{"$regex":"some2", "$options" : ""},cc:false, "$or" : [ { "dtF" : { "$gte" : { "$date" : "2012-05-06T21:00:00.000Z"}} , "dtT" : null } , { "dtF" : { "$gte" : { "$date" : "2012-05-06T21:00:00.000Z"}} , "dtT" : { "$lte" : { "$date" : "2012-06-06T21:00:00.000Z"}}}], "b":{"$in":["str1"]}}
Answer the question
In order to leave comments, you need to log in
I advise you to take a sample of the fields of the most popular requests and, based on these fields, build your own index for each request. Solve the performance problem by 80%
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question