作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用轮胎 gem ,发现了一个非常有趣的功能-custom_filters_score。
使用custom_filters_score,我可以显示按分数排序的搜索结果,分数是动态计算的。
我(几乎;-))唯一的问题是以下查询:
days = ['2013-01-17', '2013-01-18', '2013-01-19']
Tire.search 'hotels' do
query do
custom_filters_score do
query { string '*' }
filter do
filter :match_all
script "doc['my_score'].value"
end
filter do
filter :terms, 'prices.date' => days#, :minimum_match => days.size
script "100 + doc['my_score'].value"
end
score_mode 'multiply'
end
end
end
{
"id":1,
"name":"Hotel Zamkowy",
"city":"Słupsk",
"my_score":5,
"prices":[
{
"allocation":1,
"price":79,
"adults":2,
"children":0,
"date":"2013-01-17"
},
{
"allocation":1,
"price":87,
"adults":2,
"children":0,
"date":"2013-01-18"
},
{
"allocation":1,
"price":98,
"adults":2,
"children":0,
"date":"2013-01-19"
},
{
"allocation":1,
"price":75,
"adults":2,
"children":0,
"date":"2013-01-20"
},
{
"allocation":1,
"price":55,
"adults":1,
"children":0,
"date":"2013-01-16"
},
{
"allocation":1,
"price":59,
"adults":1,
"children":0,
"date":"2013-01-17"
},
{
"allocation":1,
"price":67,
"adults":1,
"children":0,
"date":"2013-01-18"
},
{
"allocation":1,
"price":78,
"adults":1,
"children":0,
"date":"2013-01-19"
},
{
"allocation":0,
"price":55,
"adults":1,
"children":0,
"date":"2013-01-20"
}
]
}
最佳答案
您应该使用:range而不是:term。类似于以下内容:
:range => {'prices.date'=> {:get =>较低价格,:lt =>较高价格}}
关于elasticsearch - 是否热衷于使用轮胎在custom_filters_score的条件过滤器上设置minimum_match?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13918331/
我是一名优秀的程序员,十分优秀!