tjSolrDoctrineBehaviorPlugin icon indicating copy to clipboard operation
tjSolrDoctrineBehaviorPlugin copied to clipboard

"400" Status: ERRORunknown_field_sf_unique_id

Open elmoby opened this issue 15 years ago • 3 comments

Hello. I'm getting this error when creating a new record into a Solr behaviour table. I've debugged the application up to it gets to $invoker->addToIndex();

This function makes a call to the __call($method, $arguments) method of sfDoctrineRecord.class.php where tries to evaluate the $method parameter whether is a "get" or a "set". But the problem is that the $method parameter is a "addToIndex" so it throws an execption and the record is not inserted.

Here is my schema config and the error trace:

ForumThread: actAs: Solr: fields: [ subject, content ] fieldmap: { subject: subject_t, content: content_t } Sluggable: fields: [subject] Timestampable: ~ options: collate: utf8_unicode_ci charset: utf8 columns: forum_id: { type: integer(11), notnull: true } user_id: { type: integer(4), notnull: true } subject: { type: string(400), notnull: true } content: { type: clob, notnull: true } posts: { type: integer(6), default: 0 } views: { type: integer(6), default: 0 } new_post: { type: boolean, notnull: true, default: 0 } relations: User: { class: sfGuardUser, local: user_id, foreign: id, type: one }

Forum: { class: Forum, local: forum_id, foreign: id, type: one }

at () in SF_ROOT_DIR/plugins/tjSolrDoctrineBehaviorPlugin/lib/vendor/solrphpclient/Service.php line 385 ...

   382.


   383.         if ($response->getHttpStatus() != 200)
   384.         {
   385.             throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
   386.         }
   387.

   388.         return $response;


*



   382. at Apache_Solr_Service->_sendRawPost('http://localhost:8983/solr/update?wt=json', '<add allowDups="false" overwritePending="true" overwriteCommitted="true"><doc><field name="sf_unique_id">ForumThread_1</field><field name="sf_meta_class">ForumThread</field><field name="sf_meta_id">1</field><field name="subject" boost="1">aaaa</field><field name="content" boost="1">bbbbb</field></doc></add>')
        in SF_ROOT_DIR/plugins/tjSolrDoctrineBehaviorPlugin/lib/vendor/solrphpclient/Service.php line 652 ...
               649.      */
               650.     public function add($rawPost)
               651.     {
               652.         return $this->_sendRawPost($this->_updateUrl, $rawPost);
               653.     }
               654.
               655.     /**
   383. at Apache_Solr_Service->add('<add allowDups="false" overwritePending="true" overwriteCommitted="true"><doc><field name="sf_unique_id">ForumThread_1</field><field name="sf_meta_class">ForumThread</field><field name="sf_meta_id">1</field><field name="subject" boost="1">aaaa</field><field name="content" boost="1">bbbbb</field></doc></add>')
        in SF_ROOT_DIR/plugins/tjSolrDoctrineBehaviorPlugin/lib/vendor/solrphpclient/Service.php line 676 ...
               673.         $rawPost .= $this->_documentToXmlFragment($document);
               674.         $rawPost .= '</add>';
               675.
               676.         return $this->add($rawPost);
               677.     }
               678.
               679.     /**
   384. at Apache_Solr_Service->addDocument(object('Apache_Solr_Document'))
        in SF_ROOT_DIR/plugins/tjSolrDoctrineBehaviorPlugin/lib/Search/Handler/Solr.php line 60 ...
                57.   public function index(array $document)
                58.   {
                59.     $doc = $this->buildDocument($document);
                60.     $this->_service->addDocument($doc);
                61.   }
                62.
                63.   /**
   385. at Search_Handler_Solr->index(array('sf_unique_id' => array('value' => 'ForumThread_1'), 'sf_meta_class' => array('value' => 'ForumThread'), 'sf_meta_id' => array('value' => '1'), 'subject' => array('value' => 'aaaa', 'boost' => 1), 'content' => array('value' => 'bbbbb', 'boost' => 1)))

elmoby avatar Sep 26 '10 11:09 elmoby

i'm getting a similar error, but here the exception talks about an unknown property "fields_array". did you solve the problem somehow?

pulse00 avatar Oct 25 '10 18:10 pulse00

do not use the getFieldsArray(), doctrine wants to find a field called "fiels_array", rename it with retreiveFieldsArray, this should work. Never use a get on a record because the _call function use it to retreive data for each column.

eljam avatar Nov 17 '10 21:11 eljam

the plugin uses the getFieldsArray() internally, so one would need to refactor the plugin. the strange thing is, that it works on all of our models, except one.

pulse00 avatar Nov 19 '10 15:11 pulse00