2012-09-29 3 views
1

안녕하세요 저는 grails searcheable 플러그인에 대한 표준 문서를 http://grails.org/Searchable+Plugin+-+Mapping+-+Class+Property+Mapping에 읽고 있습니다. 검색 가능한 참조 및 해당 구성 요소를 설명합니다. 내가 있도록이 쿼리에서 변경해야 할 일을 News.search("a phrase", params) "문구로 검색하고 있다면 내가grails 검색 플러그인 내부 검색 hasMany 클래스

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

class Comment { 
    static searchable = true 
    String text 
} 

이있는 경우 페이지에 설명 된 고전적인 시나리오에서

"뉴스의 주석과 함께 검색됩니다.

답변

0

commentscomponent로 구성하려고 :

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

이것은 당신이 News.search("componenttext:phrase", params)을 통해 특정 코멘트를 검색 할 수 있습니다,하지만 AFAIK, News.search("a phrase", params)는 코멘트를 검색합니다.

btw : 이미 루크를 발견 했습니까? http://code.google.com/p/luke/이 도구는 lucene 색인 작업을하는 동안 많은 도움을줍니다. 예를 들어, lucene이 도메인 클래스를 grails로 보는 방법을 보여줍니다.