如何使用 thinking sphinx 搜索 1970 年之前的日期?
How to search for dates before 1970 with thinking sphinx?
我的 rails 应用中有这样的搜索:
Publication.search(terms, :with => {:publish_date => start_date..end_date})
但是,如果 start_date 在 1/1/1970 之前,由于 UNIX 时间戳,结果将不会显示。我的记录在 1970 年之前有 publish_date,所以我只是想知道最好的解决方案是什么,因为我还没有找到。
您可以考虑按日期而不是时间戳将它们存储为整数:例如1970 年 1 月 1 日变为 19700101。
这确实意味着您需要在索引定义中手动将日期转换为适当的格式,并相应地转换搜索请求。
我的 rails 应用中有这样的搜索:
Publication.search(terms, :with => {:publish_date => start_date..end_date})
但是,如果 start_date 在 1/1/1970 之前,由于 UNIX 时间戳,结果将不会显示。我的记录在 1970 年之前有 publish_date,所以我只是想知道最好的解决方案是什么,因为我还没有找到。
您可以考虑按日期而不是时间戳将它们存储为整数:例如1970 年 1 月 1 日变为 19700101。
这确实意味着您需要在索引定义中手动将日期转换为适当的格式,并相应地转换搜索请求。