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, meaningT00: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 triedfacet.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
最满意答案
我可以自己提供一个几乎不能令人满意的答案,但会喜欢某人提供更好的答案。 简而言之:
- 将
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 thanreinterpret_cast<>
), but I can't say I quite understand what's going on.
相关问答
更多-
剥离linux共享库(Stripping linux shared libraries)[2023-04-13]
所以我们现在的解决方案如下: TEST.CPP #include#include #include struct private_struct { float f; }; float private_function(float f) { return std::abs(f); } void other_private_function() { std::vector f(1); } e ... -
QMetaObject :: invokeMethod:使用继承时没有这样的方法(QMetaObject::invokeMethod: No such method when using inheritance)[2023-10-08]
QMetaObject::invokeMethod只能调用Qt元对象系统已知的方法。 这些是插槽和“可调用”函数,后者在它们之前的关键字是Q_INVOKABLE 。 所以要么写: class Item : public Common { Q_OBJECT public slots: // ^^^^^ void test(QString value); }; 要么: class Item : public Common { Q_OBJECT public: Q_I ... -
如何遍历macOS应用程序的窗口,直到满足条件?(How to iterate over a macOS app’s windows until a condition is met?)[2022-07-23]
stop是一个指针,你必须设置pointee stop.pointee = true stop is a pointer, you have to set the pointee stop.pointee = true -
使用QT支持构建OpenCV时未解决的符号QMetaObject(Unresolved symbols QMetaObject when building OpenCV with QT support)[2022-10-24]
Qt MOC(元对象编译器)没有在你的Qt类文件上运行。 由于您是从OpenCV版本构建而来的,因此我假定UI类在类声明中已经有了一个Q_OBJECT行。 要生成具有运行MOC所需的生成指令的.vcproj文件,请运行以下命令: qmake -tp vc -r如果这不起作用,请右键单击包含Qt类的.h文件之一。 在Properties-> Custom Build Step-> General下,你应该看到如下所示的内容: Command Line "$(QTDIR) ... -
我可以自己提供一个几乎不能令人满意的答案,但会喜欢某人提供更好的答案。 简而言之: 将Handler移动到一个共享库确实有用......有点。 解决这个问题的唯一“简单”方法是使用reinterpret_cast
。 从某种意义上说,“我的工作”没有发现即时问题,但我确信,因为它不相信它,并且事实证明共享库解决方案只有更多的参与(我正在考虑使用动态加载而不是仅仅链接)。 这样做后,我确实得到一个QMetaObject: DEBUG: void AbstractDataView::getS ... -
在每个环境中,SCons使用变量来指定库和程序之类的东西的前缀和后缀。 这些变量基于当前正在运行的检测到的平台进行初始化......但您可以在调用Environment()构造函数后简单地覆盖此设置: env = Environment() env['SHLIBPREFIX'] = '' 对于类似“达尔文”的系统,SCons首先调用标准的“posix”初始化...这是默认的“lib”前缀来自的地方。 提示:您可以像处理字典一样对待环境(哈希映射),并设置其值,以满足您的需求。 为了显示它的当前内容,你可以 ...
-
在你的例子Sleep(1000); 阻止事件循环然后无法触发插槽。 为了使其工作有两种可能的解决方案: 使用QTimer。 在每次Sleep(1000);之前Sleep(1000); 调用QApplication::processEvents() 。 此调用将处理所有未决事件。 有关详细信息,请阅读以下答案: https : //stackoverflow.com/a/26552350/8644816 In your example Sleep(1000); is blocking the event lo ...
-
iOS或macOS项目:ViewController的重复接口定义(iOS or macOS project: duplicate interface definition for ViewController)[2023-10-31]
您需要正确设置标题搜索路径。 首先,将ALWAYS_SEARCH_USER_PATHS设置为YES 。 如果这不起作用 - 只向USER_HEADER_SEARCH_PATHS设置添加所需的标题。 You need to correctly setup your headers search paths. First, set ALWAYS_SEARCH_USER_PATHS to YES. If that will not work - add only needed headers to USER_HE ... -
您所指的lib不包含任何实际代码,但它仅用于通过提供附加信息来加载dll。 h文件也只提供有关dll函数使用的签名的信息 请查看: https : //stackoverflow.com/a/11552463/1938163 The lib you are referring to doesn't contain any actual code but it is just used to load the dll by providing additional information. The h fil ...
-
使用Java 9的Liberty macOS installUtility [重复](Liberty macOS installUtility with Java 9 [duplicate])[2023-12-21]
Liberty目前仅支持Java 7和8,我们正在努力增加对Newer Java版本的支持,但目前尚未完成。 Liberty only supports Java 7 & 8 right now, we are working on adding support for Newer Java versions, but it isn’t complete at this time.