searchkick 的查询得到错误的结果
Query of searchkick get wrong result
searchkick 的查询得到错误的结果。
我在数据库中有一条记录:
2.2.0 :047 > Product.first
#<Product id: 1, title: "Ball", description: "<p>Ball</p>\r\n", price: 10, material: "lalala", created_at: "2015-04-21 04:30:53", updated_at: "2015-04-21 04:30:53", preview: "images__1_.jpg", count: 20>
在控制器 Product
和操作 search
中我有这个代码:
def search
@products = Product.search "*", where:
{
count: 10..18
}
end
在此之后,得到一个结果,即具有此值的计数是存在的。
但是在 db count = 20 中。并且一直得到错误的结果。不知道为什么?
我得到的结果不正确,因为我在模型中没有哈希,需要重新索引模型。
模型中:
def search_data
{
count: count,
price: price,
title: title,
category_id: categories.map($:id)
}
end
之后,在 rails 控制台中写道:
Product.reindex
searchkick 的查询得到错误的结果。 我在数据库中有一条记录:
2.2.0 :047 > Product.first
#<Product id: 1, title: "Ball", description: "<p>Ball</p>\r\n", price: 10, material: "lalala", created_at: "2015-04-21 04:30:53", updated_at: "2015-04-21 04:30:53", preview: "images__1_.jpg", count: 20>
在控制器 Product
和操作 search
中我有这个代码:
def search
@products = Product.search "*", where:
{
count: 10..18
}
end
在此之后,得到一个结果,即具有此值的计数是存在的。 但是在 db count = 20 中。并且一直得到错误的结果。不知道为什么?
我得到的结果不正确,因为我在模型中没有哈希,需要重新索引模型。
模型中:
def search_data
{
count: count,
price: price,
title: title,
category_id: categories.map($:id)
}
end
之后,在 rails 控制台中写道:
Product.reindex