Page 1 of 1
Proper use of Index
Posted: Mon Jul 27, 2015 2:48 pm
by RobertJay
I've created a non-unique index for the text column State (e.g. "NY" or "CA") and have a request Where parameter set as: {"State":"NY"} - but it appears to have no effect with my server-code service. I.E. all states are being returned to my code, not just the state I'm doing the "where" on. Is there something obvious I should or should not be doing. Thanks.
Proper use of Index
Posted: Tue Jul 28, 2015 12:53 am
by Yurii Orishchuk
Hi Robert,
index is not a problem for your case.
It seems you just query collection with your search criteria incorrectly.
Please show us your server code JS code.
Regards.
Proper use of Index
Posted: Tue Jul 28, 2015 1:39 am
by RobertJay
Thank you Yurii. Just to clarify: I used the Where parameter set to {"State":"NY"} in my map associated with the server code, NOT in the server code itself. Are you saying it should be in the server code?
Proper use of Index
Posted: Sun Aug 02, 2015 10:30 pm
by RobertJay
Hello... are you OK Yurii? If so, can you please answer my question.
Proper use of Index
Posted: Mon Aug 03, 2015 2:35 am
by Yurii Orishchuk
Hi Robert,
It's hard to say why your where parameter not passed correctly to DB service
Please show us more info about your implementation:
1 Server code that you use.
2 How you invoke server code.
Also please specify does this service works when you test it in server code tester(button "SAVE and RUN")
Regards.
Proper use of Index
Posted: Mon Aug 03, 2015 3:13 pm
by RobertJay
Yurii, I'm beginning to think that my use of pagination on the calls to my server side JS from the browser (with the limit and skip parameters) interferes with the index. Does that make sense to you? If yes, is there any way of using pagination/skip/limit with an index?
Proper use of Index
Posted: Mon Aug 03, 2015 8:43 pm
by RobertJay
Yurii, does Appery support the MongoDB structure/process discussed here:
http://docs.mongodb.org/v2.2/core/geo...
That may be a perfect solution.
Proper use of Index
Posted: Tue Aug 04, 2015 2:03 am
by Yurii Orishchuk
Hi Robert,
You can use "limit" and "skip" parameters for the server code in following way:
pre
params.criteria =
{
$and: [
//First criteria, you need to replace it with yours.
{name: "lala"},
]
};
//For using projection
params.proj = {name: 1};
//For using limit
params.limit = "1";
//For using skip.
params.skip = 1;
query = Collection.query(dbId,collectionName,params,token) ;
/pre
Regards.
Proper use of Index
Posted: Tue Aug 04, 2015 2:37 am
by RobertJay
Yurii - I don't understand the relevance of your response. Please answer my question about the Mongo database that I just asked you. Thank you.
Proper use of Index
Posted: Tue Aug 04, 2015 2:20 pm
by RobertJay
Yurii, I think I'm OK. My plan is to download, learn and use cURL to create an array number field in my existing Appery collection with longitude and latitude, and use Mongo's "where/nearSphere" to hopefully get just the docs within some radius of a specific location. This may take a day or two, and I'll report my progress then. Thanks.