Grails - 可搜索插件 : Cannot search data in a one to many relationship

标签 grails searchable

对不起,如果标题不是那么具体,但我不知道如何陈述我的问题。我正在使用可搜索插件,一切都很好,直到我需要搜索与 hasMany - BelongsTo 关联的域上的信息。
例子:
我有两个类:

class Author {
  String name
  static hasMany = [books: Book]
  static searchable = true
}


class Book {
  String name
  static belongTo = [author: Author]
  static searchable = true
}

我需要能够根据书名或作者搜索一本书。
但是当调用Book.search(query, [properties:['name', author]])只搜索书名,但从不搜索作者。
我试过 author component: true (在书课上),root:false (在作者课上)没有运气。

这个问题已经花费了我几个小时,而且我确信它必须是易于实现的东西。

最佳答案

您是否尝试将 name 替换为 author.name,应该可以,
请参阅有关连接域的文档以便可搜索,luke 也是测试查询的好工具,如果没有这个工具,我无法正确 http://code.google.com/p/luke/downloads/detail?name=lukeall-3.5.0.jar&can=2&q=

关于Grails - 可搜索插件 : Cannot search data in a one to many relationship,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10100221/

相关文章:

validation - chalice : how to validate single field in command object

rest - protected Controller 在Grails应用中一个 Action 返回403,但没有另一个 Action

android 搜索不工作

grails - grails可搜索的索引null值

android - 在 ActionBar 中将数字输入类型设置为 SearchView

grails - 另一个 Grails 插件的资源插件依赖项

grails - Grails:运行应用程序错误ant-launcher-1.9.4.pom

grails - Grails可搜索插件-没有列出要索引的实体

grails - 如何以编程方式从grails中删除 Controller ?

grails - 通过GrailsDomainClassProperty区分Grails域类字段和getBlah()方法