简体   繁体   English

Solr多值日期范围从两个单独的字段作为子实体

[英]Solr Multivalued date range from two separate field as sub entity

I am a Apache Solr beginner. 我是Apache Solr的初学者。 My data-config.xml contains this code 我的data-config.xml包含此代码

<entity name="event">                        
<field column="event_id" name="id" />
...
<entity name="request_history" query="select request_date, request_expiry_date from request_history where id=event.id">
   <field column="request_date" name="start_date" />
   <field column="request_expiry_date" name="expire_date" />
</entity>

AND following is what in shcema.xml file against those fields 以下是shcema.xml文件中针对这些字段的内容

<field name="start_date" type="tdate" indexed="true" stored="true" multiValued="true"/>
<field name="expire_date" type="tdate" indexed="true" stored="true" multiValued="true"/>

So, for a single event, there can be multiple requests hence multiple "start_date" and "expire_date". 因此,对于单个事件,可能存在多个请求,因此多个“start_date”和“expire_date”。 Now I need to find all requests within a date range and all requests not within a given date range, but not getting any way. 现在,我需要查找日期范围内的所有请求以及不在给定日期范围内的所有请求,但不能获得任何方式。

Index the start date and expiry as single multivalued fields as per the event eg event_date . 根据事件(例如event_date将开始日期和到期时间索引为单个多值字段。 Rather than clubbing them into just two fields. 而不是将它们分成两个领域。
So that each event would have a entry for start date and expiry date combined and the fq=start_date:[NOW TO *] AND expire_date:[* TO NOW] query would work fine for you. 因此,每个事件都有一个开始日期和到期日期的条目,并且fq=start_date:[NOW TO *] AND expire_date:[* TO NOW]查询可以正常工作。
Make the field dynamic so that you don't need to configure. 使字段动态,以便您不需要配置。

I have found a very easy way to solve the problem, alhamdulillah. 我找到了解决问题的一种非常简单的方法,alhamdulillah。 Its a simple query pattern- 它是一个简单的查询模式 -

-(start_date: [2013-07-01T0:00:00Z TO 2013-07-18T0:00:00Z] AND end_date: [2013-07-01T0:00:00Z TO 2013-07-18T0:00:00Z]) 

This do what I need actually. 这实际上是我需要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM