Google App Engine - Searching with JDO

Google App Engine – Searching with JDO

How to perform a search in the Data Strore when there is nothing like ‘LIKE’ keyword available?
This is a short code snipped allowing you to search the data in your Google App Engine data store.

List<User> locs = new ArrayList<User>();
        Query query = pm.newQuery(User.class);
        query.setFilter("name >= '"+searchterm+"' && name < '"+searchterm+"\uFFFD'");
        query.setRange(min, max);
        try {
            locs = (List<User>)query.execute();
                ...................

Where User entity has a ‘name’ property and ‘searchterm’ is a keyword you are looking for.

Leave a Reply