Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/php/pecl-search_engine-solr

The Apache Solr PHP extension is an extremely fast, light-weight, feature-rich library that allows PHP applications to communicate easily and efficiently with Apache Solr server instances using an object-oriented API.
https://github.com/php/pecl-search_engine-solr

Last synced: about 1 month ago
JSON representation

The Apache Solr PHP extension is an extremely fast, light-weight, feature-rich library that allows PHP applications to communicate easily and efficiently with Apache Solr server instances using an object-oriented API.

Awesome Lists containing this project

README

        

================================================================================
Introducing the Solr PHP Extension
================================================================================
The Solr extension is an extremely fast, light-weight, feature-rich library that
allows PHP developers to communicate effectively with Solr server instances.

There are tools to add documents and make updates to the solr server.

It also contains tools that allows you to build advanced queries to the server
when searching for documents.

There are also special objects that simplifies the sending of name-value requests
to the server. This includes the SolrParams class and all its child classes.

The SolrClient object allows one to communicate with Solr containers that are
behind proxy servers or that require HTTP Authentication to proceed.

The SolrClient constructor accepts options such as
http authentication username and passwor, proxy server name, port, login and
passwords etc.

Using an advanced http client like libcurl allows us to leverage the features
available with the library. We can reuse the HTTP connections without having
to create a separate one for each request.

================================================================================
How to Install
================================================================================

Please refer to the README.INSTALLATION file.

================================================================================
Magic Methods and Interfaces Implemented
================================================================================

SolrDocument implements the following interfaces.

(1) ArrayAccess - to access the fields as array keys using field names.
(2) Iterator - to iterate over the document fields using foreach()
(3) Serializable - provides custom serialization of the object.

SolrDocument also contains the __get and __set magic methods which allows developers
to access the fields directly. When setting fields, if the field already
has a value the new value will be appended to the list of values for that field.

Each field is a SolrDocumentField object with the following public properties :

(a) name - a string with name of the field.
(b) boost - a double representing the boost value of the field (intentionally empty)
(c) values - an array of all the field values as strings.

Custom Serialization

string SolrDocument::serialize(void) returns an XML document representing a
SolrDocument as shown below :



A0F43D


Israel Ekpo


[email protected]


Reading
Writing
Soccer
Teaching


Inglés
Espanól

Here is a complete example of a serialized SolrDocument object:

C:12:"SolrDocument":679:{



A0F43D


Israel Ekpo


[email protected]


Reading
Writing
Soccer
Teaching


Inglés
Espanól

}

One of the items on my todo list is to create a response writer to return
serialized SolrDocument objects instead of document arrays.

SolrDocument::unserialize(string $serialized) accepts an XML document
representing the SolrDocument object. It will the bring the object back to live.

The SolrDocument class also has the method SolrDocument::getInputDocument() to
allow one do get the SolrInputDocument version of a SolrDocument instance.

This method may be helpful if one needs to resubmit the document to the server to
updates.

The Solr extension has the SolrQuery object (a child of SolrParams) that enables
the developer to send custom advanced name-value requests to the solr server.

The SolrQuery object can also be serialized and reused later, which makes it very
helpful to saving the state of the application across multiple requests. This may be
very useful in cases such as facet browsing where additional parameters may need to be
added to the current object or removed from it to get the desired results without
having to start over from scratch.

================================================================================
Parsing of XML Responses from the Solr Server
================================================================================
XML responses from the solr server are expected to be formatted using version 2.2
These xml documents are parsed into serialized php code and returned as
read-only SolrObject instances whose properties can also be accessed as array
keys in addition to being accessible directly via the object->member notation.

Having the properties accessible via object[member] notation is helpful in cases
where the property name is not valid (contains dots and other characters not
legal in php.

================================================================================
How to Report Bugs
================================================================================

Please report bugs to http://bugs.php.net

If you experience a crash due to a segmentation fault, please follow the instructions on the link below
to get a gdb backtrace and then submit the trace in your bug report as well

http://bugs.php.net/bugs-generating-backtrace.php

Thank you for using PHP