2015-02-02 3 views
1

solr PHP 클라이언트를 사용하려고합니다. 400 상태를 반환하는 문서를 추가하려고 할 때. 나는 내가 뭘 잘못하고 나는 solr에 새로운지 잘 모릅니다. 아래는 내 code 및 schema.xml 파일입니다.Solr 400 상태 : 잘못된 요청

내가 사전에 7

감사를 SOLR의 4.10.3과 바람둥이를 사용하고

$solr = new Apache_Solr_Service('localhost', '8080', '/solr/#/core0');  
if (!$solr->ping()) { 
echo 'Solr service not responding.'; 
exit; 
} else { 
$fileContent = $_GET['fileContent']; 
$title = trim($_GET['title']); 
$desription = $_GET['description']; 
$fileId = trim($_GET['fileId']); 

$docs = array(
    'doc1' => array(
     'id' => 1, 
     'fileid' => 'file1', 
     'title' => 'title1' 
)); 

$documents = array(); 
$part = new Apache_Solr_Document(); 
foreach ($docs as $item => $fields) {     
    foreach ($fields as $key => $value) { 
     if (is_array($value)) {       
      foreach ($value as $data) { 
       $part->setMultiValue($key, $data); 
      } 
     }      
     else {       
      $part->$key = $value; 
     } 
    }     

    $documents[] = $part; 
} 
// Load the documents into the index 

try { 
    $a = $solr->addDocuments($documents);     
    $solr->commit(); 
    $solr->optimize();      
} catch (Exception $e) { 
    echo $e->getMessage(); 
} 
die; 
$offset = 0; 
$limit = 10; 

$queries = array('id:'.$fileId); 

foreach ($queries as $query) { 
    $response = $solr->search($query, $offset, $limit); 
    if ($response->getHttpStatus() == 200) { 
     // print_r($response->getRawResponse()); 
     if ($response->response->numFound > 0) { 
      echo "$query <br />"; 
      foreach ($response->response->docs as $doc) { 
       echo "$doc->id $doc->title <br />"; 
      } 
      echo '<br />'; 
     } 
    } else { 
     echo $response->getHttpStatusMessage(); 
    } 
} 
} 
} 

의 schema.xml

<schema name="example core zero" version="1.1"> 
    <fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/> 
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/> 
    <field name="_version_" type="long" indexed="true" stored="true"/> 
    <field name="id" type="long" indexed="true" stored="true"/> 
    <field name="fileid" type="string" indexed="true" stored="true" required="true"/> 
    <field name="title"  type="string" indexed="true" stored="true" /> 

<uniqueKey>id</uniqueKey> 

</schema> 
+1

Solr 로그에 더 많은 정보가 있습니다 (Solr 관리 UI의 "logging"탭 참조). – Yann

+0

Logg 오후 6시 19분 53초 이 여러 RequestHandler를 같은 이름으로 등록 RequestHandlers 경고, 2015년 2월 2일으로 보여주는 :/업데이트 무시 : org.apache.solr.handler.UpdateRequestHandler 2015년 2월 2일, (6) : 21 : 39 PM ERROR ShowFileRequestHandler 찾을 수없는 항목 : admin-extra.menu-bottom.html [/usr/share/solr/example/multicore/core0/conf/admin-extra.menu-bottom.html] –

답변

0

적어도 하나의 문제는 다음과 같습니다

매개 변수 : Apache_Solr_Service의/solr/#/core0은 다음과 같아야합니다.

/solr/core0

+0

만약 내가 # 솔직히 응답하지 않는 결과를 얻고있다 # –

+0

흠 ... http://stackoverflow.com/questions/13900912/using-solr-with-php와 http : // stackoverflow를 살펴볼 것을 제안한다. co.kr/questions/6227407/a-problem-when-i-try-solr-in-php에서 문제가 발생하는 곳을 찾기 위해 디버깅에 대한 좋은 제안을 제공합니다 – Yann