我有一个像这样的日期时间字段。
<field name="rel_date" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
我尝试通过curl查询删除rel_date字段上的一些特定日期。
curl http://$SOLR_IPADDR:$SOLR_PORT/solr/update/?commit=true -H "Content-Type: text/xml" -d "<delete><query>rel_date:\[2012-03-10\])</query></delete>"
但它在SOLR响应中获得无效日期字符串错误。
HTTP状态400 - 无效的日期字符串:'[2012-03-10]'
如何使用CURL查询删除SOLR记录上的特定日期?
你也需要时间。
日期字段的格式应为1995-12-31T23:59:59Z。尾部“Z”表示UTC时间并且是强制性的(参见下面的UTC解释)。允许使用可选的小数秒,只要它们不以尾随0结尾(但是将忽略超过毫秒的任何精度)。所有其他部分都是强制性的
另见:http://lucidworks.lucidimagination.com/display/lweug/Solr+Date+Format
我是通过以下卷曲评论做到的:
curl http:// $ SOLR_IPADDR:$ SOLR_PORT / solr / update /?commit = true -H“Content-Type:text / xml”-d“(rel_date:[2012-03-10T00:00:00Z to 2012-03] -10T00:00:00Z])”
对于cource,您必须从您的环境更改$ SOLR_IPADDR和$ SOLR_PORT。
curl http://host:port/solr/core_name/update?commit=true -H“Content-Type:text / xml”--data-binary '<delete><query>rel_date:[2019-03-25T00:00:01Z TO 2019-03-25T23:59:59Z]</query></delete>'