Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding multiple values in php Solr

Tags:

php

solr

How would I go about adding multiple values to a multiValued field using the php solr extension?

like image 929
Kint Avatar asked Dec 27 '22 16:12

Kint


2 Answers

You would simply iterate the array (multiValued),
and run addField once for each of the array value.

foreach (array('Justin', 'Sean') as $coder)
{
  $doc->addField('coder', $coder);
}
like image 152
Justin Lucas Avatar answered Jan 14 '23 01:01

Justin Lucas


First:

Add a multivalued field in your solr instance, and restart it.

Second:

<?php
$multi_values = array("val-1", "val-2", "val-3");
foreach ($multi_values as $i => $value) {
    $SolrInputDocument->addField("field_name", $value, $i);
}

Its work!

view php docs here

like image 38
Will He Avatar answered Jan 14 '23 01:01

Will He