首页 \ 问答 \ Solr 1.4 Date Facet Include(Solr 1.4 Date Facet Include)

Solr 1.4 Date Facet Include(Solr 1.4 Date Facet Include)

我的目标是获取过去一年中每个月的文件数。 这是我对Solr 1.4使用的分面查询:

q=*:*
rows=0
facet=on
facet.date=myDateField
facet.date.start=NOW-11MONTH/MONTH
facet.date.end=NOW+1MONTH/MONTH
facet.date.gap=+1MONTH

此查询生成的范围是2013-01-01T00:00:00Z to 2013-02-01T00:00:00Z ,其中包含上限,表示每个月的第一天T00:00:00Z计入2个不同的范围。

Solr 3.1引入facet.date.include参数来解决我的问题,除了现在升级不是一个选项。 是否有解决方法来实现相同的功能? 我试过facet.date.gap=+1MONTH-1SECOND这是接近但不够接近。 它产生类似这样的结束日期不正确:

2012-09-01T00:00:00Z
2012-09-30T23:59:59Z
2012-10-30T23:59:58Z
2012-11-30T23:59:57Z
2012-12-30T23:59:56Z
2013-01-30T23:59:55Z
2013-02-28T23:59:54Z
2013-03-28T23:59:53Z
2013-04-28T23:59:52Z

My goal is to get a document count for each month over the past year. Here is the faceted query I am using against Solr 1.4:

q=*:*
rows=0
facet=on
facet.date=myDateField
facet.date.start=NOW-11MONTH/MONTH
facet.date.end=NOW+1MONTH/MONTH
facet.date.gap=+1MONTH

The ranges this query produces are 2013-01-01T00:00:00Z to 2013-02-01T00:00:00Z, which is inclusive for the upper bound, meaning T00:00:00Z on the first of every month is being counted in 2 different ranges.

Solr 3.1 introduces the facet.date.include parameter that would solve my problem, except upgrading right now is not an option. Is there a workaround to achieving the same functionality? I tried facet.date.gap=+1MONTH-1SECOND which is close, but not close enough. It produces something like this where the end date is not correct:

2012-09-01T00:00:00Z
2012-09-30T23:59:59Z
2012-10-30T23:59:58Z
2012-11-30T23:59:57Z
2012-12-30T23:59:56Z
2013-01-30T23:59:55Z
2013-02-28T23:59:54Z
2013-03-28T23:59:53Z
2013-04-28T23:59:52Z

原文:https://stackoverflow.com/questions/18317969
更新时间:2022-02-27 13:02

最满意答案

我可以自己提供一个几乎不能令人满意的答案,但会喜欢某人提供更好的答案。 简而言之:

  • Handler移动到一个共享库确实有用......有点。
  • 解决这个问题的唯一“简单”方法是使用reinterpret_cast<Handler*> 。 从某种意义上说,“我的工作”没有发现即时问题,但我确信,因为它不相信它,并且事实证明共享库解决方案只有更多的参与(我正在考虑使用动态加载而不是仅仅链接)。

这样做后,我确实得到一个QMetaObject:

DEBUG: void AbstractDataView::getSelected() Handler(0x7fa9eae0b9e0, name = "Export Metadata-7fa9eae0b9e0") 0x10e840350 0x10e840350

qobject_cast仍然失败! 幸运的是, dynamic_cast<>确实有效(所以我比reinterpret_cast<>更安全),但我不能说我完全理解正在发生的事情。


I can provide a barely-satisfactory answer to this myself but would love for someone to provide a better one. In short:

  • moving Handler to a shared library does work... kind of.
  • the only "simpler" way to fix this that I have found is to use reinterpret_cast<Handler*>. Which "works" in the sense I found no immediate problems, but I sure as heck don't trust it, and as it turns out the shared library solution is only barely more involved (I was thinking about using dynamic loading vs. just linking).

After doing this, I do indeed get a single QMetaObject:

DEBUG: void AbstractDataView::getSelected() Handler(0x7fa9eae0b9e0, name = "Export Metadata-7fa9eae0b9e0") 0x10e840350 0x10e840350

But the qobject_cast still fails! Fortunately, dynamic_cast<> does work (so I have something safer than reinterpret_cast<>), but I can't say I quite understand what's going on.

相关问答

更多

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)