0
votes

I want to edit document filed in solr,for example edit the author name,so i use the following code in solrj:

params.set("literal.author","anaconda")

but the author multivalued="true" in schema and because of that "anaconde" is not replace with it's previous name and add to the end of the author name,also if i ommit the multivalued field or set it to false the bad request exception happen in re-indexing file with new author field,how can i solve this problem and delete or modify the previous document field in solrj? or does it any config i miss in schema? thanks

5
Solr does not allow modifications of individual fields. If you feed Solr the same document again (having the same primary id) the existing document is deleted and the new one inserted. so if you feed a single author, thats the only data that should appear in the new document.Jayendra
so is there any way to overwrite author filed in solrj?hadi

5 Answers

4
votes

The only option I know of would be to query the full document (all fields using &fl=* parameter) into a local construct with solrj, update the appropriate field(s) and them submit the entire document back to Solr.

2
votes

Nope there is no way to update specific field for an document in Solr, nor through any of its Client apis.

EDIT :- With Solr 4.0 it it possible to Partially update the documents with certain fields.

2
votes

This post should be the correct answer to your question (if you are using SOLR 4.x)

1
votes

For Solr 4.0 you are able to update a single field on a document, but that version is ALPHA, if you are concerned.

But for the update thingy, it is only possible by CURL I think, I didnt find any way to update a single field on a doc on java side by solrj.

0
votes

You have two options:

As stated in other answers, you can query for the original document, update the field, and then re-save which will overwrite the original document with the new values.

Your other option is to install a nightly build of Solr, where Yonik has added a patch for updateable documents. You should keep an eye on https://issues.apache.org/jira/browse/SOLR-139 as this patch is pretty new and still being worked on.