Forum BigDB Find a random object with a specified range

Discussion and help relating to the PlayerIO database solution, BigDB.

Find a random object with a specified range

Postby coreyguo » May 3rd, 2013, 4:00 am

Hi all,

We're pretty new to NoSQL/BigDB and after reading through the API and example, I cannot figure out how to implement this feature:

I need to find a RANDOM opponent for my player who is for example between level 3-6 AND has a total number of 100-200 trophies AND does not have shield protection (his remaining shield time is greater than 0 seconds).

How can I do this with the existing API and Index feature in BigDB?
Basically the above example requires multiple search criteria, if I could make it work I suppose I could add infinite "AND" like I used to in MySQL database. 8-)

It seems that the methods in BigDB API are rather limited, or maybe I haven't grasped the beauty of it :mrgreen:

Thanks for your help guys!
coreyguo
Paid Member
 
Posts: 12
Joined: April 30th, 2013, 12:55 pm

Re: Find a random object with a specified range

Postby dreamora » May 3rd, 2013, 6:03 am

1. Create an index that indexes these 3 properties
2. Make a request that requests 100 elements with these specified limits
3. Choose a random element from the results you get
dreamora
 
Posts: 225
Joined: March 2nd, 2012, 9:58 am

Re: Find a random object with a specified range

Postby coreyguo » May 3rd, 2013, 7:41 am

dreamora wrote:1. Create an index that indexes these 3 properties
2. Make a request that requests 100 elements with these specified limits
3. Choose a random element from the results you get


Thanks for the response!

There's still one question about 1, how do I pass parameters for each property into one index :roll: , e.g. Level between 3 and 6, Trophies between 100 and 200, etc.

In the LoadRangeFromTable in Obj-C API, you can only specify one set of start & stop values for a certain property.
coreyguo
Paid Member
 
Posts: 12
Joined: April 30th, 2013, 12:55 pm

Re: Find a random object with a specified range

Postby Henrik » May 3rd, 2013, 2:04 pm

You can only have one property that you can get a range of values for, all others must be fixed value.

What you could do in your case is to invent a "rating" property that encapsulates all the different aspects of a player such as level, trophies, and whatever else you can think of. Then you will have that single property to do a load range on.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Find a random object with a specified range

Postby coreyguo » May 5th, 2013, 2:08 am

Henrik wrote:You can only have one property that you can get a range of values for, all others must be fixed value.

What you could do in your case is to invent a "rating" property that encapsulates all the different aspects of a player such as level, trophies, and whatever else you can think of. Then you will have that single property to do a load range on.


Makes perfect sense to me, thanks for the help :lol:
coreyguo
Paid Member
 
Posts: 12
Joined: April 30th, 2013, 12:55 pm


Return to BigDB



cron