使用比率搜索字符串,例如 find all where value gt 1:1
我在域对象和表中有一个属性,其值为 1:1, 2:1; 3:1。我正在使用可搜索插件来基于此属性进行搜索,例如,我想获取比率大于 1:1 的记录。此属性在表单上显示为复选框,当我选中该复选框时,单击“搜索”我必须获取比率大于 1:1 的所有记录。这是我的标签和方法:
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 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 method:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为文本索引是不可能的,除非可能的值集非常有限——比如只有“2:1”、“1:1”和“1:2”。在后一种情况下,您只需指定显式的值列表。
是否可以将字段拆分为 2 个数字字段?
现在,如果像“7:7”这样的值有效,甚至不可能使用 Hibernate 进行正确搜索。如果只有“1:X”和“X:1”是可能的,那么我就选择
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