php_solr
[ class tree: php_solr ] [ index: php_solr ] [ all elements ]

Class: SolrQuery

Source Location: /src/search/SolrQuery.php

Class Overview


A query for Solr's StandardRequestHandler.


Author(s):

Constants

Methods



Class Details

[line 74]
A query for Solr's StandardRequestHandler.

Please note that this library operates with UTF-8 strings, just like Solr. Because of that, it is mandatory that all strings passed to any of SolrQuery's methods (especially the fields and the query itself) are encoded in UTF-8.

Please have a look at SolrSimpleFacets if you want to use faceting.

Example: Sending the query "php mysql" and applying the filter "year:[2005 TO *]" to it.

  1.  require_once 'php_solr/Solr.php';
  2.  Solr::autoload('SolrQuery');
  3.  
  4.  $query new SolrQuery('php mysql');
  5.  $query->setFilters('year:[2005 TO *]');
  6.  
  7.  $solr Solr::connect();
  8.  $result $solr->query($query);




Tags:

property-read:  SolrSimpleFacets $facets: Facets
author:  Alexander M. Turek <rabus@users.sourceforge.net>
see:  http://wiki.apache.org/solr/SolrQuerySyntax
see:  http://wiki.apache.org/solr/StandardRequestHandler
since:  0.3.0


[ Top ]


Class Methods


constructor __construct [line 182]

SolrQuery __construct( string $query)

Constructor for SolrQuery.



Tags:

access:  public


Parameters:

string   $query   The query.

[ Top ]

method getQueryString [line 198]

string getQueryString( [string $solrSpecVersion = null])

Build the query string of the URL for this query.



Tags:

access:  public
uses:  urlencode()


Parameters:

string   $solrSpecVersion   The servers specification version (optional).

[ Top ]

method setDefaultField [line 329]

void setDefaultField( [string $defaultField = null])

Sets the default field for this query.

Passing null or calling this function without a parameter resets your setting to the server default.




Tags:

access:  public


Parameters:

string   $defaultField  

[ Top ]

method setFieldList [line 261]

void setFieldList( [string|array(string) $fields = null])

Sets the list of fields to return.

This parameter can be used to specify a set of fields to return, limiting the amount of information in the response. When returning the results to the client, only fields in this list will be included.

The string "score" can be used to indicate that the score of each document for the particular query should be returned as a field, and the string "*" can be used to indicate all stored fields the document has.

Examples

  1.  // Only return the "id", "name", and "price" fields
  2.  $query->setFieldList(array('id''name''price'));
  3.  
  4.  // Return the "id" field and the score
  5.  $query->setFieldList(array('id''score'));
  6.  
  7.  // Return all fields the each document has
  8.  $query->setFieldList('*');
  9.  
  10.  // Return all fields each document has, along with the score
  11.  $query->setFieldList(array('*''score'));

Passing null or calling this function without a parameter resets your setting to the server default.

Please note that Solr is unable to provide the value of fields that are not marked as stored in your Schema.xml!




Tags:

access:  public


Parameters:

string|array(string)   $fields  

[ Top ]

method setFilters [line 298]

void setFilters( [string|array(string) $filters = null])

Sets the filter queries for this query.

This parameter can be used to specify one ore multiple queries that can be used to restrict the super set of documents that can be returned, without influencing score.

Passing null or calling this function without a parameter drops all filters.




Tags:

since:  0.3.2
access:  public


Parameters:

string|array(string)   $filters  

[ Top ]

method setOperator [line 354]

void setOperator( [string $operator = null])

Specify the default operator.

Specifies the default operator for query expressions, overriding the default operator specified in Solr's schema.xml. Possible values are OP_AND or OP_OR.

Passing null or calling this function without a parameter resets your setting to the server default.

Example: Setting the default operator to AND.

  1.  $query->setOperator(SolrQuery::OP_AND);




Tags:

access:  public


Parameters:

string   $operator  

[ Top ]

method setRows [line 372]

void setRows( [integer $rows = null])

Sets the maximum number of documents.

When specified, this parameter indicates the maximum number of documents from the complete result set to return to the client for every request.

Passing null or calling this function without a parameter resets your setting to the server default.




Tags:

access:  public


Parameters:

integer   $rows  

[ Top ]

method setStart [line 396]

void setStart( [integer $start = null])

Sets the offset for the returned result set.

When specified, this parameter indicates the offset in the complete result set for the queries where the set of returned documents should begin.

Passing null or calling this function without a parameter resets your setting to the server default.




Tags:

access:  public


Parameters:

integer   $start  

[ Top ]

method __get [line 160]

mixed __get( string $property)

Getter for magic properties.



Tags:

access:  public


Parameters:

string   $property   The parameter.

[ Top ]


Class Constants

FACET_SORT_COUNT =  'count'

[line 89]

Sort facet by count.


[ Top ]

FACET_SORT_LEX =  'lex'

[line 96]

Sort facet lexicographically.


[ Top ]

OP_AND =  'AND'

[line 78]

AND operator.


[ Top ]

OP_OR =  'OR'

[line 82]

OR operator.


[ Top ]



Documentation generated on Wed, 20 May 2009 12:51:11 +0000 by phpDocumentor 1.4.2