2012-09-29 65 views
1

你好,我正在閱讀grails可搜索插件的標準文檔http://grails.org/Searchable+Plugin+-+Mapping+-+Class+Property+Mapping它描述了可搜索引用和組件。grails可搜索插件在內部hasMany類中搜索

在,如果我有

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

class Comment { 
    static searchable = true 
    String text 
} 

如果我被News.search("a phrase", params)什麼我要在此查詢改變使「短語搜索頁面上討論的經典場景「被搜索到新聞以及新聞的評論?

回答

0

嘗試配置commentscomponent

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

這可以讓你通過News.search("componenttext:phrase", params)搜索特定的評論,但據我所知,News.search("a phrase", params)還將通過評論進行搜索。

btw:你已經發現了盧克? http://code.google.com/p/luke/這個工具將在處理lucene索引時幫助你很多。例如,它向您展示了lucene如何看待您的grails域類。