views:

560

answers:

1

when i do a standard search it just search for one field type.

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

when i try this:

$params = array('qf' => 'threads.title posts.body');
$results = $solr->search($query, $offset, $limit, $params);

it still doesnt work.

any idea?

+3  A: 

I think that to search in multiple fields you should do something like this:

$results = $solr->search('threads.title:'.$query.' OR posts.body:'.$query, $offset, $limit, $params);

To search efficiently you should define index on these two fields joined together and search in that index.

Kamil Szot
u mean with copyfield? but if i do that, would it still return the fields seperatly so i know in which field the result was in?
weng
Solr lets you define fields that it remembers and the fields that it can search among. You can instruct it in schema.xml to remember fields threds.title and post.body separately but search in index that is defined as these to fields joined together. Then you will be able to search in those two fields combined but get separate values of these two fields in results. It's all about indexed="true|false" and stored="true|false" in field definitions.
Kamil Szot
You can use copyfield or even just put concatenated value of these two fields in this additional field while feeding solr with data.
Kamil Szot