2012-07-09 3 views
1

내 grails 애플리케이션에서 검색 가능한 플러그인을 사용하여 다음과 같이 "오퍼링"인스턴스를 검색합니다. 검색 서비스를이 인스턴스를 제공하는 매핑 된 속성에서 적절한 안타를 반환 예상대로Grails 앱에서 검색어와 위치로 검색

def search = { 
    must(queryString(params.query)) 
} 

def searchResult = searchableService.search(search, params) 

을 제공하는 클래스의 다음 매핑

검색 설정

class Offering { 

    static searchable = { 
     only: ['title', 'description'] 
    } 

    String title 
    String description 

    Category category 
    Location location 

    BigDecimal price 
    PricePeriod pricePeriod 

    static belongsTo = [user: SecUser] 

    static constraints = { 
     title(blank: false, maxSize: 100) 
     description(blank: false, maxSize: 10240) 
     category(nullable: false) 
     location(nullable: false) 
     price(nullable: true, scale: 2) 
     pricePeriod(nullable: true) 
    } 

    public String toString() { 
     return title 
    } 

} 

전화. 오퍼링 모음

내가 지금하고 싶은 것은 검색어뿐만 아니라 위치의 Offerings 하위 요소도 검색합니다. 특히 하위 위치 인스턴스 내의 "locationName"필드. 그래서

나는 "브리즈번"나는 "locationName"속성의 일치 "브리즈번"

가진 아이 위치 인스턴스와 제품 매칭 "저녁 식사"의 컬렉션을 좀하고 싶습니다 쿼리 "저녁 식사"와 위치에 따라 검색하는 경우 검색 가능한 플러그인을 사용하여 구현할 위치에 대한 아이디어가 있습니까? 당신의 도움에 대한

위치 클래스

class Location { 

    String locationName 
    Location locationParent 
    String postcode 

    static hasMany = [locations: Location] 

    static constraints = { 
     locationName(blank: false, unique: true) 
     locationParent(nullable: true) 
     postcode(nullable: true) 
    } 

    public String toString() { 
     return locationName 
    } 
} 

덕분에

답변

0

나는 싶은 것은의 라인을 따라 뭔가 생각 :

class Offering { 

    ... 

    static searchable = { 
     only: ['title', 'description'] 
     location component: true 
    } 

    ... 
} 

class Location { 

    ... 

    static searchable = { 
     only: ['locationName'] 
     location component: true 
    } 

    ... 
} 
관련 문제