简体   繁体   中英

Grails searchable component option

Where are two domains

class State {
  String name

  static searchable = {
    only: 'name'
  }
}

class Region {
  State state
  String name

  static searchable = {
    state component: true
    only: 'name'
  }
}

I want to find only regions by region name or all regions of state by state name. States should not be in search result.

How I have to change the code?
PS I know how to find objects by gorm. I wrote just simple example of code. I need lucene for featured search

Region by region name In SearchableService

def search(String state){
 def stateSearch = State.findByName(region);
 return stateSearch
 }

Find all region of state by state In searchableService

def regionSearch(String region, String state){
 def state = state.findByName(state);
 def region = Region.findByState(state);
return return
}

Hopefully this work.If not, please paste your code in the service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM