Google datastore Filter

Source: Internet
Author: User
Import com. Google. appengine. API. datastore. datastoreservicefactory;
Import com. Google. appengine. API. datastore. datastoreservice;
Import com. Google. appengine. API. datastore. query. filter;
Import com. Google. appengine. API. datastore. query. filterpredicate;
Import com. Google. appengine. API. datastore. query. filteroperator;
Import com. Google. appengine. API. datastore. query. compositefilter;
Import com. Google. appengine. API. datastore. query. compositefilteroperator;
Import com. Google. appengine. API. datastore. query;
Import com. Google. appengine. API. datastore. preparedquery;
Import com. Google. appengine. API. datastore. entity;

// Get the datastore Service
Datastoreservice datastore = datastoreservicefactory. getdatastoreservice ();

Filter heightminfilter =
New filterpredicate ("height ",
Filteroperator. greater_than_or_equal,
Minheight); // a query corresponds to a Filter Using filterpredicate; heightmaxfilter =
New filterpredicate ("height ",
Filteroperator. less_than_or_equal,
Maxheight );

// Use compositefilter to combine multiple Filters
Filter heightrangefilter =
Compositefilteroperator. And (heightminfilter, heightmaxfilter); // use compositefilter to build a filter for multiple filters in a query.



Filter


// Use class query to assemble a query
Query q = new query ("person"). setfilter (heightrangefilter );

// Use preparedquery interface to retrieve results
Preparedquery PQ = datastore. Prepare (Q );


For (entity result: PQ. asiterable ()){
String firstname = (string) result. getproperty ("firstname ");
String lastname = (string) result. getproperty ("lastname ");
Long Height = (long) result. getproperty ("height ");

System. Out. println (firstname + "" + lastname + "," + height + "inches tall ");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.