简体   繁体   中英

How can I use Grails Searchable (lucene) to perform the equivalent Criteria query the most efficient way

I am searching against a single Domain class, but also trying to allow wildcard queries against 2 String fields, I understand wildcard (first character) queries are supposed to be inefficient however if only against 2 fields, then perhaps that's not so significant.

I'm trying to accomplish what would be the follow as a criteria query..

MyDomain.createCriteria().list {
  and {
    notEqual('deleted',true)
    or {
      ilike('field1','%' + searchText + '%')
      ilike('field2','%' + searchText + '%')
    }
  } 
}

Any suggestions much appreciated, thanks.

一个lucene查询看起来像:

-deleted:true +(field1:searchText field2:searchText)

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