4
我有domain class User,它与domain class LibraryElement有多对多的关系。我试图过滤属于用户的所有库元素,其中包含特定的文本。这是搜索的属性和关系是如何定义的:Grails可搜索插件多对多搜索
用户侧:
static searchable = {
id name: 'userId'
libraryElements component: true
}
static hasMany = [libraryElements: LibraryElement]
LibraryElement方:
static searchable = {
users component: true
}
static belongsTo = User
static hasMany = [users: User]
我试图执行搜索这样的:
LibraryElement.search("userId:" + userId + " libraryElementName:" + searchWord + "*")
即使在数据库中有一个数据应该被这个搜索命中,我也会得到0个结果。
什么是libraryElementName,我没有看到它在LibraryElement中,可以请详细说明。 –
它是LibraryElement域内的字符串字段。 – rastko