[英]Using boolean filter on Tire with OR
我在Rails应用程序上使用Tire,但是缺少文档确实让我感到沮丧。 我知道该宝石是“ ReTire”,但在更换为其他宝石之前,我需要使用它。
我在像这样简单的查询的过滤器上遇到问题
SELECT product FROM products WHERE (price = 20 OR productID = "XHDK-A-1293-#fJ3") AND (price = 30)
我已经在Elastic Search字符串查询中做到了:
GET /my_store/products/_search
{
"query" : {
"filtered" : {
"filter" : {
"bool" : {
"should" : [
{ "term" : {"price" : 20}},
{ "term" : {"productID" : "XHDK-A-1293-#fJ3"}}
],
"must" : {
"term" : {"price" : 30}
}
}
}
}
}
}
简单而有效! 但是我不知道如何在轮胎结构上做到这一点。 我已经尝试了很多解决方案,但都无济于事。
我需要一条解决之道。
您有没有尝试过以下方法?
Tire.search 'products' do
query do
boolean do
should { string 'price:20' }
should { string 'productID:XHDK-A-1293-#fJ3' }
must { string 'price:30' }
end
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.