4

I have entity:

Entity e = new Entity("Item");
e.setProperty("Description", Description);

And I am trying to perform a keyword search. Ex, If i have "abc", "eabcd" and "abc block", when I perform the search "abc", it should return all three.

If I am using SQL, I would say something like this:

Select * from Item where Description like "%"+keyword+"%"

I know I can do this, but this will only return "abc".

public static Iterable<Entity> SearchItems(String Description) {
    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    Query q = new Query("Item").addFilter("Description",
            FilterOperator.EQUAL, Description);
    return ds.prepare(q).asIterable();
}

What should I do?

P.S. I have seen this but this is not particularly helpful. Google App Engine and SQL LIKE

Community
  • 1
  • 1
user2214756
  • 133
  • 1
  • 6

1 Answers1

4

What you need is a full text search, and App Engine datastore does not support that. You need to use the App Engine Search API to do such queries.

However, the API does not support applying the full text queries to the datastore, you need to build and store your data in indexed documents. You might need to consider duplicating the data in your datastore and store it again in the indexed document storage.

Ibrahim Arief
  • 7,840
  • 4
  • 32
  • 53
  • Interesting. Thank you for your reply! I hope they will eventually implement a function for "like" search because this is so important for so many functions. (Especially to those of us who are new to GAE and are so used to doing searches in SQL's.) – user2214756 Mar 28 '13 at 06:11