[英]Using boolean filter on Tire with OR
I'm using Tire on my Rails application, but the lack of documentation really frustrated me. 我在Rails应用程序上使用Tire,但是缺少文档确实让我感到沮丧。 I know the gem is "ReTire" but I need use him until I change to other gem.
我知道该宝石是“ ReTire”,但在更换为其他宝石之前,我需要使用它。
I have a problem on filter like this simple query 我在像这样简单的查询的过滤器上遇到问题
SELECT product FROM products WHERE (price = 20 OR productID = "XHDK-A-1293-#fJ3") AND (price = 30)
I already did it on Elastic Search string query: 我已经在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}
}
}
}
}
}
}
It's simple and worked! 简单而有效! But I don't know how to make this on Tire structure.
但是我不知道如何在轮胎结构上做到这一点。 I already tried a lot of solutions, none worked.
我已经尝试了很多解决方案,但都无济于事。
I need a path to the solution. 我需要一条解决之道。
Have you tried the following by any chance? 您有没有尝试过以下方法?
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.