2011-03-27 95 views
0

我從數據庫直接導入數據到solr索引。現在我想用php-solr-client進行搜索。現在我想要搜索它:如何搜索整個solr索引?

$offset = 0; 
$limit = 10; 

$queries = array(
    'details:Server' 
); 

$response = $solr->search($query, $offset, $limit); 

現在我只能在指定字段時搜索,例如, details。有沒有辦法一次搜索所有字段?

回答

1

如果您省略了details:,是不是它搜索索引的所有字段?

否則,你總是可以在一個查詢中合併多個領域是這樣的:

details:Server OR field2:Server OR field3:Server

編輯:關於默認字段進行搜索,指定將與多個值來填充一個「虛擬」字段:

<field name="text" type="text" indexed="true" stored="false" multiValued="true"/> 

所有字段然後讓copyField條目將被搜索:

<copyField source="title" dest="text"/> 
<copyField source="akatitle" dest="text"/> 
<copyField source="year" dest="text"/> 

最後,指定本場應該是默認的一個:

<defaultSearchField>text</defaultSearchField> 

這應該工作。

+0

你是什麼意思省略? – 2011-03-27 14:18:58

+0

根本不使用它,只是'Server',我認爲這是有效的Lucene查詢語法。 – jishi 2011-03-27 14:20:04

+0

當我忘了字段名稱我沒有得到任何搜索結果,對我來說也很奇怪 – 2011-03-27 14:22:19