Ok, thanks for all the help :)... just kidding.
I finally found a way to emulate range and sort on merge-join queries. Here
is my solution:
*My old entity:*
Product {
double price;
list<string> attributes;
}
*The old query:*
query.filter("attributes", "something").filter("attributes",
"somethingElse"); // ZigZag, no composite indexes, that means that sort and
inequality filters are not allowed
*The solution:* save ranges of prices into the entity
*The ranges I choose:*
- every 10
- every 50
- every 100
- every 200
- every 400
- every 800
*The new entity:*
Product {
double price;
list<string> attributes;
list<string> priceRanges;
}
*Examples: **(every range is named {from}_{to})*
1. $75 -> priceRanges: ["70_80", "50_100", "0_100", "0_200", "0_400",
"0_800"].
2. $680 -> priceRanges: ["680_690", "650_700", "600_700", "600_800",
"400_800", "0_800"].
*To query any predefined price range (i.e between $200 and $400):*
query.filter("attributes", "something").filter("attributes",
"somethingElse").filter("priceRanges", "200_400"); // Still ZigZag!
*Now to get a dirty sorting (but useful):*
If you need this range: from $200 to $400 sorted ASC you can emulate it
doing many subqueries for smaller ranges and putting it all together.
i.e: if you need the first 20 rows of $200 <= price < $400
1. query for 200_210
2. got 20 ? return : query the next price range;
I didn't implement any of these yet, so I really welcome any comments or
advices before I mess with the code.
Thanks!
On Wed, Nov 17, 2010 at 2:27 AM, Gal Dolber <[email protected]> wrote:
> My situation:
> I have a list of "Products" with a price and other indexed properties(not
> the same ones on each product), and I query them using merge-join.
> I really need to get the results of the merge-join sorted by price.
> Any advice?
> Good in-memory solutions are welcome
>
> Thanks in advance
>
> --
> Guit: Elegant, beautiful, modular and *production ready* gwt applications.
>
> http://code.google.com/p/guit/
>
>
>
>
>
--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.
http://code.google.com/p/guit/
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.