[英]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.