我坚持使用新的本地安装solr。在某一点上,每件事情都可以正常工作。
我可以毫无问题地访问solr的管理员:http://localhost:8983/solr/admin/
但是当我索引我的mysql内容时,我会抛出错误:
更新请求失败。响应代码0.(null)
,没有别的。我到处看了一下,但我真的无法弄清楚问题出在哪里和哪里。
有什么想法吗?
以下是有关我尝试索引的内容的一些信息:
schema.xml中的字段:
<field name="pl_album_id" type="string" indexed="true" stored="true" required="true" />
<field name="pl_album_num_id" type="int" indexed="true" stored="true" required="true" />
<field name="pl_album_title" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_album_number" type="int" indexed="true" stored="true"/>
<field name="pl_album_keywords" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_album_summary" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_album_general_mark" type="int" indexed="true" stored="true"/>
<field name="pl_album_authors" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_album_signer_id" type="int" indexed="true" stored="true" multiValued="true"/>
<field name="pl_album_format" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_album_is_complete" type="int" indexed="true" stored="true"/>
<field name="pl_album_status_id" type="int" indexed="true" stored="true"/>
<field name="pl_album_sort_status_id" type="int" indexed="true" stored="true"/>
<field name="pl_album_is_online" type="int" indexed="true" stored="true"/>
<field name="pl_album_review_created_at" type="date" indexed="true" stored="true"/>
<field name="pl_album_review_year" type="int" indexed="true" stored="true"/>
<field name="pl_series_id" type="int" indexed="true" stored="true"/>
<field name="pl_series_title" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_series_title_copy_for_sorting" type="string" indexed="true" stored="true"/>
<field name="pl_series_prefix" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_series_type_id" type="int" indexed="true" stored="true"/>
<field name="pl_series_origin_id" type="int" indexed="true" stored="true"/>
<field name="pl_series_genre_id" type="int" indexed="true" stored="true" multiValued="true"/>
<field name="pl_series_genres" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_series_targeted_public_id" type="int" indexed="true" stored="true" multiValued="true"/>
<field name="pl_collection_id" type="int" indexed="true" stored="true"/>
<field name="pl_collection_label" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_publisher_id" type="int" indexed="true" stored="true"/>
<field name="pl_publisher_name" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_published_at" type="date" indexed="true" stored="true"/>
<field name="pl_visit_counter" type="int" indexed="true" stored="true"/>
<field name="pl_user_id" type="int" indexed="true" stored="true"/>
<field name="pl_user_first_name" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_user_last_name" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_cycle_type_id" type="int" indexed="true" stored="true"/>
<field name="pl_cycle_title" type="text_general_fr" indexed="true" stored="true"/>
<field name="pl_cycle_number" type="int" indexed="true" stored="true"/>
我使用该函数对它们进行索引:
public function solrIndex($AlbumId = null)
{
$album = new Album();
$album_list = $album->getForSolrIndex($AlbumId);
$options = array
(
'hostname' => sfConfig::get('plconfig_solr_hostname'),
'port' => sfConfig::get('plconfig_solr_port')
);
$solr_client = new SolrClient($options);
foreach($album_list as $album_details)
{
$solr_client->deleteByQuery("pl_album_num_id:".$album_details['id']);
}
$solr_client->commit();
foreach($album_list as $album_details)
{
$doc = new SolrInputDocument();
$doc->addField('pl_album_id', $album_details['id']);
$doc->addField('pl_album_num_id', $album_details['id']);
$doc->addField('pl_album_title', $album_details['title']);
if($album_details['number'])
{
$doc->addField('pl_album_number', $album_details['number']);
}
$doc->addField('pl_album_keywords', $album_details['keywords']);
$doc->addField('pl_album_summary', $album_details['summary']);
if($album_details['general_mark'])
{
$doc->addField('pl_album_general_mark', $album_details['general_mark']);
}
$doc->addField('pl_album_authors', $album_details['authors']);
$doc->addField('pl_album_is_complete', $album_details['album_is_complete'] ? $album_details['album_is_complete'] : 0);
$doc->addField('pl_album_status_id', $album_details['status_id'] ? $album_details['status_id'] : 0);
$sort_status_id = 8;
if($album_details['status_id'] == Album::TO_REREAD)
{
$sort_status_id = 1;
}
if($album_details['status_id'] == Album::TO_IMPROVE)
{
$sort_status_id = 2;
}
if($album_details['status_id'] == Album::TO_REVIEW)
{
$sort_status_id = 3;
}
if($album_details['status_id'] == Album::TO_RECEIVE)
{
$sort_status_id = 4;
}
if($album_details['status_id'] == Album::ONLINE)
{
$sort_status_id = 5;
}
if($album_details['status_id'] == Album::ABANDON_BY_PUBLISHER)
{
$sort_status_id = 6;
}
if($album_details['status_id'] == Album::ABANDON_BY_PLANETEBD)
{
$sort_status_id = 7;
}
$doc->addField('pl_album_sort_status_id', $sort_status_id);
$doc->addField('pl_album_format', $album_details['format']);
$doc->addField('pl_album_is_online', $album_details['is_online'] ? $album_details['is_online'] : 0);
if($album_details['album_review_created_at'])
{
$doc->addField('pl_album_review_created_at', date('Y-m-d\TH:i:s\Z', strtotime($album_details['album_review_created_at'])));
$doc->addField('pl_album_review_year', date('Y', strtotime($album_details['album_review_created_at'])));
}
$doc->addField('pl_series_id', $album_details['series_id']);
$doc->addField('pl_series_title', $album_details['series_title']);
$doc->addField('pl_series_title_copy_for_sorting', $album_details['series_title']);
$doc->addField('pl_series_prefix', $album_details['series_prefix']);
if($album_details['type_id'])
{
$doc->addField('pl_series_type_id', $album_details['type_id']);
}
$doc->addField('pl_series_genres', $album_details['series_genres']);
$doc->addField('pl_series_origin_id', $album_details['series_origin_id'] ? $album_details['series_origin_id'] : 0);
$doc->addField('pl_collection_id', $album_details['collection_id'] ? $album_details['collection_id'] : 0);
$doc->addField('pl_collection_label', $album_details['label']);
$doc->addField('pl_publisher_id', $album_details['publisher_id']);
$doc->addField('pl_publisher_name', $album_details['name']);
if($album_details['published_at'])
{
$doc->addField('pl_published_at', $album_details['published_at'].'T00:00:00Z');
}
$doc->addField('pl_visit_counter', $album_details['visit_counter'] ? $album_details['visit_counter'] : 0);
$doc->addField('pl_user_id', $album_details['user_id'] ? $album_details['user_id'] : 0);
$doc->addField('pl_user_first_name', $album_details['user_first_name']);
$doc->addField('pl_user_last_name', $album_details['user_last_name']);
$doc->addField('pl_cycle_type_id', $album_details['cycle_type_id'] ? $album_details['cycle_type_id'] : 0);
$doc->addField('pl_cycle_title', $album_details['cycle_title']);
$doc->addField('pl_cycle_number', $album_details['cycle_number'] ? $album_details['cycle_number'] : 0);
foreach($album_details['signers'] as $signer_id) {
$doc->addField('pl_album_signer_id', $signer_id);
}
foreach($album_details['genres'] as $genre_id) {
$doc->addField('pl_series_genre_id', $genre_id);
}
foreach($album_details['targeted_public'] as $targeted_public_id) {
$doc->addField('pl_series_targeted_public_id', $targeted_public_id);
}
$updateResponse = $solr_client->addDocument($doc);
}
$solr_client->commit();
return count($album_list);
}
答案 0 :(得分:0)
您使用的Solr版本是什么?是Solr4吗?你在架构中定义了吗?