GQL:查找包含子字符串的所有实体 [英] GQL: Find all entities that contain a substring

查看:104
本文介绍了GQL:查找包含子字符串的所有实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些具有StringProperty的实体,我想查询所有匹配子字符串的实体。有没有一种方法可以仅使用GQL?



例如,如果我的数据存储看起来像这样:

  ID /名称question_text 
-------------------------------- ------------------------------
3001我喜欢吃鸡肉。
3020我只喜欢吃被炸的鸡肉。
3045我喜欢菲力牛排。
3052我喜欢奶酪。

GQL查询会在question_text中找到所有包含'chicken'的实体吗?

解决方案

您正在寻找的是通过StringProperty进行全文搜索。这就是 SearchableModel 创建的。

基本上,它会在您的实体上创建一个新属性,该属性是文本字段中所有字符串的列表(我相信二元和三元) ,使用任务队列。然后通过GQL查询来完成搜索鸡,比如 SELECT * FROM WHERE'chicken'IN strings_list


I have some entities that have a StringProperty and I would like to query for all the entities that match a substring. Is there a way to do that using just GQL?

For example, if my datastore looks like this:

ID/Name     question_text
--------------------------------------------------------------
3001        I like to eat chicken.
3020        I only like to eat chicken that is deep fried.
3045        I like filet mignon.
3052        I like cheese.

What would the GQL query be to find all the entities that contain 'chicken' in question_text?

解决方案

What you're looking for is full-text search over a StringProperty. This is what SearchableModel was created for.

Basically, it creates a new property on your entity that is a list of all the strings (and I believe bi- and tri-grams) in the text field, using the task queue. Then searching for "chicken" is done by a GQL query like SELECT * FROM whatever WHERE 'chicken' IN strings_list

这篇关于GQL:查找包含子字符串的所有实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆