Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.
Example Usage (see also http://code.google.com/p/solr-php-client/wiki/ExampleUsage): <code> ... $solr = new Apache_Solr_Service(); //or explicitly new Apache_Solr_Service('localhost', 8180, '/solr')
$solr->deleteByQuery('*:*'); //deletes ALL documents - be careful :)
$document->title = 'Some Title'; $document->content = 'Some content for this wonderful document. Blah blah blah.';
$solr->addDocument($document); //if you're going to be adding documents in bulk using addDocuments //with an array of documents is faster
$solr->commit(); //commit to see the deletes and the document $solr->optimize(); //merges multiple segments into one
//and the one we all care about, search! //any other common or custom parameters to the request handler can go in the //optional 4th array argument. $solr->search('content:blah', 0, 10, array('sort' => 'timestamp desc')); ... </code>
Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
Constants
Name
Value
SVN_REVISION
'$Revision$'
SVN_ID
'$Id$'
SVN_URL
'$HeadURL$'
SOLR_WRITER
'json'
NAMED_LIST_FLAT
'flat'
NAMED_LIST_MAP
'map'
METHOD_GET
'GET'
METHOD_POST
'POST'
PING_SERVLET
'admin/ping'
UPDATE_SERVLET
'update'
SEARCH_SERVLET
'select'
SYSTEM_SERVLET
'admin/system'
THREADS_SERVLET
'admin/threads'
EXTRACT_SERVLET
'update/extract'
Members
protected
$_collapseSingleValueArrays
—
boolean Whether {@link Apache_Solr_Response} objects should have multivalue fields with only a single value collapsed to appear as a single value would.
$_createDocuments
—
boolean Whether {@link Apache_Solr_Response} objects should create {@link Apache_Solr_Document}s in the returned parsed data
$_namedListTreatment
—
string How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values are {@link Apache_Solr_Service::NAMED_LIST_MAP} (default) or {@link Apache_Solr_Service::NAMED_LIST_FLAT}.
$_pingUrl
—
string Constructed servlet full path URLs
$_queryDelimiter
—
string Query delimiters. Someone might want to be able to change these (to use & instead of & for example), so I've provided them.
$_urlsInited
—
boolean Keep track of whether our URLs have been constructed
Methods
protected
_constructUrl()
— Return a valid http URL given this server's host, port and path and a provided servlet name
_documentToXmlFragment()
— Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call
addDocuments()
— Add an array of Solr Documents to the index all at once
commit()
— Send a commit command. Will be synchronous unless both wait parameters are set to false.
delete()
— Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document
deleteById()
— Create a delete document based on document ID
deleteByMultipleIds()
— Create and post a delete document based on multiple document IDs.
deleteByQuery()
— Create a delete document based on a query and submit it
escape()
— Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
escapePhrase()
— Escape a value meant to be contained in a phrase for special query characters
extract()
— Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how to use Solr Cell and what parameters are available.
extractFromString()
— Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how to use Solr Cell and what parameters are available.
extractFromUrl()
— Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how to use Solr Cell and what parameters are available.
setCreateDocuments()
— Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will parse the response and create {@link Apache_Solr_Document} instances in place.
setDefaultTimeout()
— Set the default timeout for all calls that aren't passed a specific timeout
setHost()
— Set the host used. If empty will fallback to constants
setHttpTransport()
— Set the HTTP Transport implemenation that will be used for all HTTP requests
setNamedListTreatment()
— Set how NamedLists should be formatted in the response data. This mainly effects the facet counts format.
setPath()
— Set the path used. If empty will fallback to constants
setPort()
— Set the port used. If empty will fallback to constants
setQueryDelimiter()
— Set the string used to separate the path form the query string.
setQueryStringDelimiter()
— Set the string used to separate the parameters in thequery string Defaulted to '&'
system()
— Call the /admin/system servlet and retrieve system information about Solr
threads()
— Call the /admin/threads servlet and retrieve information about all threads in the Solr servlet's thread group. Useful for diagnostics.