Вопрос

I have a datetime field like that.

<field name="rel_date" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>

I try to delete some specific dates on rel_date field by curl query.

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>"

But its getting Invalid date string error on SOLR response.

HTTP Status 400 - Invalid Date String:'[2012-03-10]'

How can I delete specific dates on SOLR records with CURL query?

Это было полезно?

Решение

You need the time as well.

From the DateField javadocs:

A date field shall be of the form 1995-12-31T23:59:59Z The trailing "Z" designates UTC time and is mandatory (See below for an explanation of UTC). Optional fractional seconds are allowed, as long as they do not end in a trailing 0 (but any precision beyond milliseconds will be ignored). All other parts are mandatory.

See also: http://lucidworks.lucidimagination.com/display/lweug/Solr+Date+Format

Другие советы

I did it with following curl comment:

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])"

Of cource you have to change $SOLR_IPADDR and $SOLR_PORT from your environment.

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>'

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top