On Apr 13, 2009, at 11:20 AM, Johnny X wrote:


Also, in reference to the other question, I'm currently trying to edit the
main search page to search multiple fields.

Essentially, I detect if each field has been posted or not using:

if ($_POST['FIELD'] != '') {
$query = $query . '+FIELDNAME:' . $_POST['FIELD'];
}

Once it's processed all the fields, its then sent to query solr, but I'm not sure if I'm getting the syntax right or if there's anything in the Solr config file I need to modify (dismax?) because it still only returns results when I enter a search in the 'content' field (also the default Solr field).

My Solr query looks like:

   $query = "?q=".trim(urlencode($query)).
       '&version=2.2&start=0&rows=999999&indent=on';

where $query will look something like "Content: 35 million+Date: 16th Oct"
etc, until it has been urlencoded/trimmed.

Will it still only return results on 'content' searches because that's the
only default field?

You'll need to read up on Lucene/Solr query parser syntax to be able to build useful queries programatically like that: <http://wiki.apache.org/solr/SolrQuerySyntax > Your syntax above is not doing what you might think... you'll want to surround expressions with quotes or in parens for a single field. Content:(35 million) for example.

It'll be best if you decouple your questions about query parsing from PHP code though. And don't forget that &debugQuery=true is your friend, so you can see how queries are being parsed. Providing that output would be helpful to see what is actually happening with what you're sending.

        Erik


Reply via email to