1
<fields>
<field name="mongo_id" type="string" indexed="true" stored="true" required="true" />
<field name="nid" type="int" indexed="true" stored="true" required="true" />
<field name="keywords" type="text_general" indexed="true" stored="false" />
</fields>
我想找回所有匹配關鍵字的nid(不同)。Solr根據關鍵字搜索不同的「nids」
$solr = new Apache_Solr_Service(SOLR_HOST, SOLR_PORT, SOLR_WEBAPP);
//How would I search here?
$results = $solr->search('search', 0, 100);
編輯:
這是否正確?
$solr = new Apache_Solr_Service(SOLR_HOST, SOLR_PORT, SOLR_WEBAPP);
$results = $solr->search(Apache_Solr_Service::escapePhrase($_GET['keywords']), 0, 0, array('facet' => 'true', 'facet.field' => 'nid', 'rows' => 0, 'facet.mincount' => 1));
foreach($results->facet_counts->facet_fields->nid as $nid=>$count)
{
$nids[] = (int)$nid;
}
我的編輯看起來不錯嗎? – 2012-03-13 21:33:38
我沒有使用PHP Solr服務,所以我不能肯定地說,但對於我未經訓練的眼睛,它看起來確定。 – 2012-03-13 21:39:42