Pooya Saberian
Pooya Saberian

Reputation: 1061

PHP Solarium: Updating Parts of Documents

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.

Upvotes: 1

Views: 2156

Answers (1)

MatsLindh
MatsLindh

Reputation: 52912

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

Upvotes: 5

Related Questions