-
Notifications
You must be signed in to change notification settings - Fork 16
/
README
executable file
·154 lines (122 loc) · 6.06 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
================================================================================
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 :
<?xml version="1.0" encoding="UTF-8"?>
<solr_document>
<fields>
<field name="id">
<field_value>A0F43D</field_value>
</field>
<field name="name">
<field_value>Israel Ekpo</field_value>
</field>
<field name="email">
<field_value>[email protected]</field_value>
</field>
<field name="skills">
<field_value>Reading</field_value>
<field_value>Writing</field_value>
<field_value>Soccer</field_value>
<field_value>Teaching</field_value>
</field>
<field name="languages">
<field_value>Inglés</field_value>
<field_value>Espanól</field_value>
</field>
</fields>
</solr_document>
Here is a complete example of a serialized SolrDocument object:
C:12:"SolrDocument":679:{<?xml version="1.0" encoding="UTF-8"?>
<solr_document>
<fields>
<field name="id">
<field_value>A0F43D</field_value>
</field>
<field name="name">
<field_value>Israel Ekpo</field_value>
</field>
<field name="email">
<field_value>[email protected]</field_value>
</field>
<field name="skills">
<field_value>Reading</field_value>
<field_value>Writing</field_value>
<field_value>Soccer</field_value>
<field_value>Teaching</field_value>
</field>
<field name="languages">
<field_value>Inglés</field_value>
<field_value>Espanól</field_value>
</field>
</fields>
</solr_document>
}
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 [email protected]
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