My datastore has stored entities with a timestamp and relevance. I want to 
get the most relevant results from today, this week, month, or all time. 
The first sort would be timestamp, followed by relevance, pulling 10 at a 
time. However, this:

Filter timeMaxFilter = new FilterPredicate("timestamp",
                FilterOperator.GREATER_THAN_OR_EQUAL,
                getEarlierTimeStamp(Calendar.HOUR, -24)); 
if(timeFrame.equalsIgnoreCase("day")){
timeMaxFilter = new FilterPredicate("timestamp",
                     FilterOperator.GREATER_THAN_OR_EQUAL,
                     getEarlierTimeStamp(Calendar.HOUR, -24));
q.setFilter(timeMaxFilter);
}
q.addSort("relevance");
PreparedQuery pq = datastore.prepare(q);
for (Entity result : pq.asList(withLimit(10).offset(10*pageNumber))) {
}

*Generates this error message:*

[INFO] java.lang.IllegalArgumentException: The first sort property must be 
the s
ame as the property to which the inequality filter is applied.  In your 
query th
e first sort property is relevance but the inequality filter is on 
relevance.
[INFO]  at 
com.google.appengine.api.datastore.DatastoreApiHelper.translateError(
DatastoreApiHelper.java:53)

I understand why- they reindex in order of timestamp, because they want to 
be able to return the query in flat time, so they require me to sort by 
timestamp first. However, I feel like they can't be putting such a strict 
requirement on their customers. I could probably pull back ALL results in 
order of relevance, and then pull off the top 10. However, that seems 
wasteful. Is there a better way? If not, how would I set a FilterOrder with 
no limit, meaning ALL of the entries so I could sort them on my end?

Thanks,
-Keith

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/a1c82fee-5389-4458-b778-b7f8d8df74b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to