Note that there are some explanatory texts on larger screens.

plurals
  1. POSearching by query and location in Grails app
    primarykey
    data
    text
    <p>I am using the searchable plugin in my grails application to search for "Offering" instances in the following way.</p> <p>Search setup with following mapping in Offering class</p> <pre><code>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 } } </code></pre> <p>Call to searchable service</p> <pre><code> def search = { must(queryString(params.query)) } def searchResult = searchableService.search(search, params) </code></pre> <p>As expected this returns appropriate hits from the mapped properties of Offering instances. A collection of offerings</p> <p>What I would like to do now is search not only by the search query but also the Offerings child element of location. Specifically the "locationName" field within the child Location instance.</p> <p>So if I search by query "dinner" and location "Brisbane" I would like to get a collection of offerings matching "dinner" with a child location instance with the "locationName" property matching "Brisbane"</p> <p>Any ideas on where to start to implement something like this using the searchable plugin?</p> <p>Location class</p> <pre><code>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 } } </code></pre> <p>Thanks for your help </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload