4
我有實體:Google App Engine,Java Datastore Query:如何做SQL Like語句?
Entity e = new Entity("Item");
e.setProperty("Description", Description);
,我試圖進行關鍵字搜索。例如,如果我有「abc」,「eabcd」和「abc block」,當我執行搜索「abc」時,它應該返回全部三個。
如果我使用SQL,我要說的是這樣的:
Select * from Item where Description like "%"+keyword+"%"
我知道我能做到這一點,但這隻會返回「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();
}
我該怎麼辦?
P.S.我已經看到了這一點,但這不是特別有用。 Google App Engine and SQL LIKE
有趣。謝謝您的回覆! 我希望他們最終會實現一個「喜歡」搜索的功能,因爲這對於如此多的功能非常重要。 (尤其對於我們這些剛接觸GAE並習慣於在SQL中進行搜索的人)。 – user2214756 2013-03-28 06:11:43