*This might be very simple question but I can't figure out after i tried to
google all day.

I just want the data to show like this*

/"record": [
    {
       id: "product001"
       name: "iPhone case",
      title: {
          th: "เคส ไอโฟน5 iphone5 Case วิบวับ ลายผสมมุกสีชมพู back case",
          en: "iphone5 Case pinky pearl back case"
   }
]/

*and this is my schema.xml*

/<field name="title" type="text_th" indexed="true" stored="true"
multiValued="true"/>
/

*this is my php code*

<?php

require_once( 'SolrPhpClient/Apache/Solr/Service.php' );
                $solr = new Apache_Solr_Service( 'localhost', '8983', './solr' 
);
                
                if( !$solr->ping() ) {
                  echo "Solr service is not responding";
                  exit;
                }

        $parts = array(
            'spark_plug' => array(
              'id' => 11,
              'name' => 'Spark plug',
              'title' => array(
                'th' => 'เคส sdsdไอโฟน4 iphone4 Case วิบวับ ลายหอไอเฟลสุดเก๋ 
สีชมพูเข้ม
ปปback case',
                'en' => 'New design Iphone 4 case with pink and beutiful back 
case '
                   ),
              'model' => array( 'a'=>'Boxster', 'b'=>'924' ),
              'price' => 25.00,
              'inStock' => true,
            ),
            'windshield' => array(
              'id' => 2,
              'name' => 'Windshield',
              'model' => '911',
              'price' => 15.50,
              'inStock' => false,
              'url'=>'http://store.weloveshopping.com/joeishiablex12'
            )
                );

$documents = array();
          
          foreach ( $parts as $item => $fields ) {
             $doc = new Apache_Solr_Document();
            
            foreach ( $fields as $key => $value ) {
              if ( is_array( $value ) ) {
                foreach ( $value as $datum ) {
                  $doc->setMultiValue( $key, $datum );
                }
              }
              else {
                $doc->$key = $value;
              }
            }
            
            $documents[] = $doc;
          }

                try
                        {
                                $solr->addDocuments($documents);
                                $solr->commit();
                                $solr->optimize();
                        }
                catch(Exeption $e)
                        {
                                echo $e->getMessage();
                        }

?>

*but the response that I'm getting now like below as you see it has no key (
th or en) in response*

/"record": [
    {
       id: "product001"
       name: "iPhone case",
      title: {
           "เคส ไอโฟน5 iphone5 Case วิบวับ ลายผสมมุกสีชมพู back case",
           "iphone5 Case pinky pearl back case"
   }
]/


*Please help, million thanks 
Chun.*



--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-index-data-in-muliValue-field-with-key-tp4110653.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to