RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Proper use of Index

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.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Proper use of Index

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.

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Proper use of Index

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?

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Proper use of Index

Hello... are you OK Yurii? If so, can you please answer my question.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Proper use of Index

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.

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Proper use of Index

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?

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Proper use of Index

Yurii, does Appery support the MongoDB structure/process discussed here:

http://docs.mongodb.org/v2.2/core/geo...

That may be a perfect solution.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Proper use of Index

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.

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Proper use of Index

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.

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Proper use of Index

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.

Return to “Issues”