Searching string with ratio like find all where value gt 1:1
I have a property in domain object and table which have values 1:1, 2:1; 3:1. I am using searchable plugin to search based this property like, I want to get the records whose ratio is greater than 1:1. This property is shown as check box on form and when I check the box, click on Search I have to get all the records with ratios greater than 1:1. Here is my tag and m开发者_如何学JAVAethod:
tag: <input type="checkbox" name="query" value=="1:1" />
search method:
//Ratio greater than 1:1
if(params.query[20]){
String searchTerm = "2:1"
println searchTerm
return [searchResult: searchableService.search(searchTerm, params)]
}
I am unable to get the result set. Please let me know how to do this.
Thanks ayrus
I don't think it's possible with text indexing, unless the set of possible values is pretty limited - like only '2:1', '1:1' and '1:2'. In latter case, you can just specify explicit list of values.
Is it possible to split the field into 2 numeric ones?
Now it's even impossible to correctly search with Hibernate, if values like '7:7' are valid. If only '1:X' and 'X:1' are possible then I'd just go with
DomainClass.withCriteria {
like(score, '%:1')
ne(score, '1:1')
}
精彩评论