【问题标题】:grails searcheable plugin search in inner hasMany class内部hasMany类中的grails可搜索插件搜索
【发布时间】:2012-09-29 06:07:44
【问题描述】:

您好,我正在阅读http://grails.org/Searchable+Plugin+-+Mapping+-+Class+Property+Mapping 的 grails 可搜索插件的标准文档,其中描述了可搜索的引用和组件。

如果我有页面上讨论的经典场景

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

class Comment {
    static searchable = true
    String text
}

如果我通过News.search("a phrase", params) 进行搜索,我必须在此查询中进行哪些更改,以便将“短语”搜索到新闻和新闻组中?

【问题讨论】:

    标签: grails groovy grails-searchable


    【解决方案1】:

    尝试将comments配置为component

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

    这允许您通过 News.search("componenttext:phrase", params) 搜索特定的 cmets,但是 afaik,News.search("a phrase", params) 也将通过 cmets 进行搜索。

    顺便说一句:你已经发现卢克了吗? http://code.google.com/p/luke/ 在使用 lucene 索引时,这个工具会给你很多帮助。例如,它向您展示了 lucene 如何看待您的 grails 域类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-17
      相关资源
      最近更新 更多