Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

php - How to search whole solr index?

I import data from database directly into the solr index. Now I want to search it using php-solr-client. Now I want to search it:

$offset = 0;
$limit = 10;

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

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

For now I can only search when I specify the field, e.g. details. Is there a way to search all fields at a time?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you omit the details:, doesn't it search all fields that are indexed?

Otherwise, you can always combine multiple fields in one query like this:

details:Server OR field2:Server OR field3:Server

EDIT: Regarding default field to search, specify a "dummy" field that would be populated with multiple values:

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

Then have copyField entries for all fields that would be searched:

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

And finally, specify that this field should be the default one:

<defaultSearchField>text</defaultSearchField>

That should work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...