简体   繁体   English

PHP Solarium:更新部分文档

[英]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. 我想用PHP Solarium更新Apache Solr 4.0中文档的一部分,而不要更新整个文档。 I know its possible in Solr ( documentation in Solr ), I just cant find any documentation on how to do this in Solarium. 我知道它在Solr中是可能的(Solr中的文档 ),我只是在Solarium中找不到有关如何执行此操作的任何文档。 all the existing Solarium documentation point me to updating the whole document, which is problematic and unnecessary. 所有现有的Solarium文档都指向我更新整个文档,这是有问题且不必要的。

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". 请记住,更新Solr文档中的字段要求您将所有相关字段设置为已存储-Solr将在后台检索并重新添加完整的文档,因此部分更新可能不会出现“有问题”或“不必要”的情况。 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. 好的索引策略是始终能够从原始源快速重新创建(和重新索引)您的文档,因为在索引时应用了Solr转换。

With that being said, Solarium supports partial updates by using setFieldModifier . 话虽如此,Solarium 通过使用setFieldModifier支持部分更新

$doc2 = $update->createDocument();
$doc2->setKey('id', 1);

$doc2->addField('price', '100');
$doc2->setFieldModifier('price', 'set');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM