Google应用程序引擎-在python中搜索stringProperty

Google应用程序引擎-在python中搜索stringProperty,python,string,google-app-engine,properties,Python,String,Google App Engine,Properties,我是新的Google应用程序引擎,所以我从Python的HelloWorld和留言簿教程开始 现在我想在我的类中查询特定的字符串,但在GAE文档中找不到相应的文档 我有以下资料: class song_key(genre) #We use genre as the key for a Song entity return ndb.Key('Repository',genre) class Singer(ndb.Model): name = ndb.StringPrope

我是新的Google应用程序引擎,所以我从Python的HelloWorld和留言簿教程开始

现在我想在我的类中查询特定的字符串,但在GAE文档中找不到相应的文档

我有以下资料:

class song_key(genre)
    #We use genre as the key for a Song entity
    return ndb.Key('Repository',genre)

class Singer(ndb.Model):
    name = ndb.StringProperty()
    birthday = ndb.DateProperty()

class Song(ndb.Model):
    author = ndb.StructuredProperty(Singer)
    title = ndb.StringProperty()
    release = ndb.DateProperty()
    dateAdd = ndb.DateTimeProperty(auto_now_add=True)
我想找到所有作者为“约翰·列侬”的歌曲,假设它们都属于同一“流派”

我试过一些东西,比如:

q = Song.query((Song.author.name == "John Lennon'), ancestor=song_key(genre)).order(-Song.data)
results = q.all()
但这显然不是进行此查询的方法

有人能帮我理解谷歌应用程序引擎中的查询吗?实现这种stringProperty查询的好方法是什么

我已经经历了或者说,但是我在理解整个概念时遇到了一些问题^^

编辑:以下是两个查询的结果:

Query(kind='Song', ancestor=Key('Repository', 'Pop'), orders=...)

[Song(key=Key('Repository', 'Pop', 'Song', 5733953138851840), author=Singer(name=u'John Lennon'), date=datetime.datetime(2016, 2, 13, 22, 59, 31, 766373),title=u'Come Together'), Song(key=Key('Repository', 'Pop', 'Song', 5556931766779904), author=Singer(name=u'Bruno Mars'), date=datetime.datetime(2016, 2, 13, 16, 15, 58, 584174), title=u'Uptown Funk), Song(key=Key('Repository', 'Pop', 'Song', 6119881720201216), author=Singer(name=u'Katty Perry'), date=datetime.datetime(2016, 2, 13, 16, 15, 30, 915749), title=u'Teenage Dream')]
我有三个条目

当我想按作者姓名筛选时:

Query(kind='Song', ancestor=Key('Repository', 'Pop'), filters=FilterNode('author.name', '=', 'John Lennon'), orders=...)

[]
空名单


谢谢大家!

好的,我找到了一个类似蟒蛇的方法来解决我的问题: 我查询特定流派的所有歌曲,然后检查我要找的歌手是否属于此列表

q = Song(ancestor=repository_key(genre))
results = p.fetch()

songs = []
for result in results:
    if author in result.author.name:
        songs.append(result)

为什么“显然”不是这样?如果要查询singer属性,为什么要将其设为index=False?song_key()类应该做什么。这有点奇怪我从留言簿教程开始,但你完全正确。我将歌手属性编入索引:)song_key()是音乐实体的“流派”。与留言簿教程中的“留言簿键”一样,我使用歌曲键收集不同“流派”类别下的所有歌曲条目。我还添加了一个查询结果。