1 <?php 2 $options = array 3 ( 4 ‘hostname‘ => ‘localhost‘, 5 ‘port‘ => ‘8080‘, 6 ‘path‘=>‘solr/help_category‘, 7 ‘wt‘=>‘json‘ 8 ); 9 $client = new SolrClient($options); 10 11 12 $doc = new SolrInputDocument(); 13 14 $doc->addField(‘id‘, 501000); 15 $doc->addField(‘title‘, ‘Hello Wolrd‘); 16 // $fields=$doc->getField (‘id‘); 17 // var_dump($fields);exit; 18 $response = $client->addDocument($doc); 19 var_dump($response); 20 $client->commit(); 21 ?>
当索引文档中主键id值存在时,会更新原文档,不存在则会添加文档
时间: 2024-11-07 16:28:22