I want to update parts of a document in Apache Solr 4.0 with PHP Solarium, and not update the whole document. I know its possible in Solr (documentation in Solr), I just cant find any documentation on how to do this in Solarium. all the existing Solarium documentation point me to updating the whole document, which is problematic and unnecessary.
Asked
Active
Viewed 2,058 times
1 Answers
5
Remember that updating fields in a Solr document requires you to have all relevant fields set as stored - Solr will retrieve and re-add the complete document in the background, so a partial update might not be any less "problematic" or "unnecessary". A good indexing strategy is to always be able to re-create (and re-index) your document quickly from the original source because of Solr transformations being applied when indexing.
With that being said, Solarium supports partial updates by using setFieldModifier
.
$doc2 = $update->createDocument();
$doc2->setKey('id', 1);
$doc2->addField('price', '100');
$doc2->setFieldModifier('price', 'set');

MatsLindh
- 49,529
- 4
- 53
- 84
-
similar like this how can i increment an int value in solr 7 document WITH SOLARIUM CLIENT – Yabes Nadar Jun 22 '18 at 07:40
-
@YabesNadar Use `inc` instead of `set`. But comments isn't the place to ask a question - create an actual question for that. – MatsLindh Jun 22 '18 at 07:53