grails searcheable plugin search in inner hasMany class

二次信任 提交于 2019-12-08 04:50:36

问题


Hello I am reading the standard documentation for grails searcheable plugin at http://grails.org/Searchable+Plugin+-+Mapping+-+Class+Property+Mapping It describes searcheable references and components in that.

In the classic scenario discussed on the page if I have

class News {
    static searchable = true
    static hasMany = [comments: Comment]
    String text
}

and

class Comment {
    static searchable = true
    String text
}

If I am searching by News.search("a phrase", params) what do I have to change in this query so that "a phrase" is searched into news as well as comments of news?


回答1:


try to configure comments as component:

class News {
  static searchable = true
  static hasMany = [comments: Comment]
  String text
  static searchable = {
    comments component: [prefix:'comment']
  }
}

This allows you to search for a specific comments through News.search("componenttext:phrase", params), but afaik, News.search("a phrase", params) will also search through the comments.

btw: have you already discovered luke? http://code.google.com/p/luke/ This tool will help you a lot while working with the lucene index. For instance, it shows you how lucene sees you grails domain class.



来源:https://stackoverflow.com/questions/12650402/grails-searcheable-plugin-search-in-inner-hasmany-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!