組件我使用Apache的Solr的-3.5.0,我想做出這樣的:http://www.kaufda.de/BerlinSolr的建議者 「自動完成」 用PHP
(樂句建議)
我曾經建議者 - (靈活的「 http://css.dzone.com/news/solr-and-autocomplete-part-2
這是我solrconfig:
自動完成」組件,用於SOLR)是喜歡這篇文章中的說明
<searchComponent name="suggest" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<str name="field">name_autocomplete</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="org.apache.solr.handler.component.SearchHandler">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.count">10</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
Shema.xml
<fieldType class="solr.TextField" name="text_auto">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="name" type="text" indexed="true" stored="true" multiValued="false" />
<field name="name_autocomplete" type="text_auto" indexed="true" stored="true" multiValued="false" />
<field name="description" type="text" indexed="true" stored="true" multiValued="false" />
<copyField source="name" dest="name_autocomplete" />
在我的PHP代碼:
$solr = $this->getSolr();
$response = NULL;
if (!$solr) {
return;
}
$params = array();
$params['spellcheck.build'] = 'true';
$params['spellcheck'] = 'true';
$params['qt'] = '';
$result = $solr->search('har', 0, 10, $params);
結果是不建議的陣列。
我該如何使用Suggester和php?
感謝的提前幫助
乾杯
您好,感謝快速響應,它工作正常,但是當我在php中使用這個參數我無法得到這個結果 – ZendMind 2012-02-16 12:04:48
嗨,我是這個'$ result = $ solr-> search('har',0,10,$ params);'錯了? solr建議者有另外一個參數嗎? – ZendMind 2012-02-17 11:14:03
我不知道你用什麼庫來與solr進行交互。您需要確保它發送寫查詢。看看這個http://www.php.net/manual/en/solrquery.setquery.php – 2012-02-17 11:50:11