我正在使用solr,我想在SOLR中使用UNION和MINUS的组合。我已经制定了oracle查询。
select * from TESTTABLE where (FT = 'PE' and emis between 10 and 20) or (FT = 'DI' and emis between 10 and 15)
union (
select * from TESTTABLE where (FT <> 'PE' or emis not between 10 and 20) and (FT <> 'DI' or emis not between 10 and 15)
minus
select * from TESTTABLE where (FT = 'PE' and emis not between 10 and 20) or (FT = 'DI' and emis not between 10 and 15)
);
我想制定一个等价的SOLR。请阿西斯我将oracle查询转换为SOLR。
2条答案
按热度按时间9gm1akwq1#
您应该能够在Solr中构建它,只需考虑以下因素:
1.您可以像在sql中一样使用括号
1.记住把所有的都放在一个fq里面,用
*:*
表示q1.注意“NOT x”,在solr中有时你需要一点技巧来使它正确工作,参见here for examples。可能取决于solr的版本
h4cxqtbf2#
举个例子:在Comics和Filmography中获取年龄范围为10到25的图书,并假设有三个字段bookName、bookType和age i,将执行以下操作:-
q=图书类型:漫画书类型:电影类型&fq=年龄:[10至25]
主查询中的两个bookType子句之间没有间隔意味着OR,即带来漫画或电影,并且过滤器查询中的年龄范围,即fq过滤掉年龄不在10到25之间的结果。