In my solr schema (Solr4.1) I have 2 fields
<timestamp>
<status>
I want to update/change the status of documents over 14 days old but not delete them from the index.
I delete them currently like this
curl http://localhost/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>timestamp:[* TO NOW-14DAYS] </query></delete>'
im wondering if i can change the status field to some nominal text value "expired" or "archived" etc based on the documents age as determined by the timestamp value.
Thanks
I was able to resolve this in the following manner. It seems Solr can delete by query etc but not update by query. Im my case I simply wanted to update a field of a document, not reindex the doc, not delete it, just update it based on its age (eg expire a document but still have it in the index so it can be found if wanted).
What I did was use the csv response writer, I saved the query timestamp:[* TO NOW-14DAYS] to a csv file. Now I have a csv file with all the documents from the above query (or any query you need)
You can then do a quick find/replace on the value you want to change eg "published" change to "unpublished" or something. Save the csv. Re index/commit.
Took about 5 minutes all up.
Solr4.x really needs a update field by query(s) but this was a real easy work around that came to me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.