Sorry, search is unavailable right now
Try again later?
43 | * ...
44 | * $document->title = 'Something';
45 | * echo $document->title;
46 | * ...
47 | *
48 | *
49 | * Additionally, the field values can be iterated with foreach
50 | *
51 | *
52 | * foreach ($document as $fieldName => $fieldValue)
53 | * {
54 | * ...
55 | * }
56 | *
57 | */
58 | class Apache_Solr_Document implements IteratorAggregate
59 | {
60 | /**
61 | * SVN Revision meta data for this class
62 | */
63 | const SVN_REVISION = '$Revision: 54 $';
64 |
65 | /**
66 | * SVN ID meta data for this class
67 | */
68 | const SVN_ID = '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
69 |
70 | /**
71 | * Document boost value
72 | *
73 | * @var float
74 | */
75 | protected $_documentBoost = false;
76 |
77 | /**
78 | * Document field values, indexed by name
79 | *
80 | * @var array
81 | */
82 | protected $_fields = array();
83 |
84 | /**
85 | * Document field boost values, indexed by name
86 | *
87 | * @var array array of floats
88 | */
89 | protected $_fieldBoosts = array();
90 |
91 | /**
92 | * Clear all boosts and fields from this document
93 | */
94 | public function clear()
95 | {
96 | $this->_documentBoost = false;
97 |
98 | $this->_fields = array();
99 | $this->_fieldBoosts = array();
100 | }
101 |
102 | /**
103 | * Get current document boost
104 | *
105 | * @return mixed will be false for default, or else a float
106 | */
107 | public function getBoost()
108 | {
109 | return $this->_documentBoost;
110 | }
111 |
112 | /**
113 | * Set document boost factor
114 | *
115 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
116 | */
117 | public function setBoost($boost)
118 | {
119 | $boost = (float) $boost;
120 |
121 | if ($boost > 0.0)
122 | {
123 | $this->_documentBoost = $boost;
124 | }
125 | else
126 | {
127 | $this->_documentBoost = false;
128 | }
129 | }
130 |
131 | /**
132 | * Add a value to a multi-valued field
133 | *
134 | * NOTE: the solr XML format allows you to specify boosts
135 | * PER value even though the underlying Lucene implementation
136 | * only allows a boost per field. To remedy this, the final
137 | * field boost value will be the product of all specified boosts
138 | * on field values - this is similar to SolrJ's functionality.
139 | *
140 | *
141 | * $doc = new Apache_Solr_Document();
142 | *
143 | * $doc->addField('foo', 'bar', 2.0);
144 | * $doc->addField('foo', 'baz', 3.0);
145 | *
146 | * // resultant field boost will be 6!
147 | * echo $doc->getFieldBoost('foo');
148 | *
149 | *
150 | * @param string $key
151 | * @param mixed $value
152 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
153 | */
154 | public function addField($key, $value, $boost = false)
155 | {
156 | if (!isset($this->_fields[$key]))
157 | {
158 | // create holding array if this is the first value
159 | $this->_fields[$key] = array();
160 | }
161 | else if (!is_array($this->_fields[$key]))
162 | {
163 | // move existing value into array if it is not already an array
164 | $this->_fields[$key] = array($this->_fields[$key]);
165 | }
166 |
167 | if ($this->getFieldBoost($key) === false)
168 | {
169 | // boost not already set, set it now
170 | $this->setFieldBoost($key, $boost);
171 | }
172 | else if ((float) $boost > 0.0)
173 | {
174 | // multiply passed boost with current field boost - similar to SolrJ implementation
175 | $this->_fieldBoosts[$key] *= (float) $boost;
176 | }
177 |
178 | // add value to array
179 | $this->_fields[$key][] = $value;
180 | }
181 |
182 | /**
183 | * Handle the array manipulation for a multi-valued field
184 | *
185 | * @param string $key
186 | * @param string $value
187 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
188 | *
189 | * @deprecated Use addField(...) instead
190 | */
191 | public function setMultiValue($key, $value, $boost = false)
192 | {
193 | $this->addField($key, $value, $boost);
194 | }
195 |
196 | /**
197 | * Get field information
198 | *
199 | * @param string $key
200 | * @return mixed associative array of info if field exists, false otherwise
201 | */
202 | public function getField($key)
203 | {
204 | if (isset($this->_fields[$key]))
205 | {
206 | return array(
207 | 'name' => $key,
208 | 'value' => $this->_fields[$key],
209 | 'boost' => $this->getFieldBoost($key)
210 | );
211 | }
212 |
213 | return false;
214 | }
215 |
216 | /**
217 | * Set a field value. Multi-valued fields should be set as arrays
218 | * or instead use the addField(...) function which will automatically
219 | * make sure the field is an array.
220 | *
221 | * @param string $key
222 | * @param mixed $value
223 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
224 | */
225 | public function setField($key, $value, $boost = false)
226 | {
227 | $this->_fields[$key] = $value;
228 | $this->setFieldBoost($key, $boost);
229 | }
230 |
231 | /**
232 | * Get the currently set field boost for a document field
233 | *
234 | * @param string $key
235 | * @return float currently set field boost, false if one is not set
236 | */
237 | public function getFieldBoost($key)
238 | {
239 | return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : false;
240 | }
241 |
242 | /**
243 | * Set the field boost for a document field
244 | *
245 | * @param string $key field name for the boost
246 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
247 | */
248 | public function setFieldBoost($key, $boost)
249 | {
250 | $boost = (float) $boost;
251 |
252 | if ($boost > 0.0)
253 | {
254 | $this->_fieldBoosts[$key] = $boost;
255 | }
256 | else
257 | {
258 | $this->_fieldBoosts[$key] = false;
259 | }
260 | }
261 |
262 | /**
263 | * Return current field boosts, indexed by field name
264 | *
265 | * @return array
266 | */
267 | public function getFieldBoosts()
268 | {
269 | return $this->_fieldBoosts;
270 | }
271 |
272 | /**
273 | * Get the names of all fields in this document
274 | *
275 | * @return array
276 | */
277 | public function getFieldNames()
278 | {
279 | return array_keys($this->_fields);
280 | }
281 |
282 | /**
283 | * Get the values of all fields in this document
284 | *
285 | * @return array
286 | */
287 | public function getFieldValues()
288 | {
289 | return array_values($this->_fields);
290 | }
291 |
292 | /**
293 | * IteratorAggregate implementation function. Allows usage:
294 | *
295 | *
296 | * foreach ($document as $key => $value)
297 | * {
298 | * ...
299 | * }
300 | *
301 | */
302 | public function getIterator()
303 | {
304 | $arrayObject = new ArrayObject($this->_fields);
305 |
306 | return $arrayObject->getIterator();
307 | }
308 |
309 | /**
310 | * Magic get for field values
311 | *
312 | * @param string $key
313 | * @return mixed
314 | */
315 | public function __get($key)
316 | {
317 | if (isset($this->_fields[$key]))
318 | {
319 | return $this->_fields[$key];
320 | }
321 |
322 | return null;
323 | }
324 |
325 | /**
326 | * Magic set for field values. Multi-valued fields should be set as arrays
327 | * or instead use the addField(...) function which will automatically
328 | * make sure the field is an array.
329 | *
330 | * @param string $key
331 | * @param mixed $value
332 | */
333 | public function __set($key, $value)
334 | {
335 | $this->setField($key, $value);
336 | }
337 |
338 | /**
339 | * Magic isset for fields values. Do not call directly. Allows usage:
340 | *
341 | *
342 | * isset($document->some_field);
343 | *
344 | *
345 | * @param string $key
346 | * @return boolean
347 | */
348 | public function __isset($key)
349 | {
350 | return isset($this->_fields[$key]);
351 | }
352 |
353 | /**
354 | * Magic unset for field values. Do not call directly. Allows usage:
355 | *
356 | *
357 | * unset($document->some_field);
358 | *
359 | *
360 | * @param string $key
361 | */
362 | public function __unset($key)
363 | {
364 | unset($this->_fields[$key]);
365 | unset($this->_fieldBoosts[$key]);
366 | }
367 | }
--------------------------------------------------------------------------------
/SolrPhpClient/Apache/Solr/Exception.php:
--------------------------------------------------------------------------------
1 |
37 | */
38 |
39 | class Apache_Solr_Exception extends Exception
40 | {
41 | /**
42 | * SVN Revision meta data for this class
43 | */
44 | const SVN_REVISION = '$Revision: 54 $';
45 |
46 | /**
47 | * SVN ID meta data for this class
48 | */
49 | const SVN_ID = '$Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
50 | }
--------------------------------------------------------------------------------
/SolrPhpClient/Apache/Solr/HttpTransport/Abstract.php:
--------------------------------------------------------------------------------
1 | , Donovan Jimenez type Status report
message unknown handler: standad
description The request sent by the client was syntactically incorrect (unknown handler: standad).
type Status report
message /solr/doesnotexist/select
description The requested resource (/solr/doesnotexist/select) is not available.
Found %d results for %s in %.3f seconds.
" 40 | "div>" 41 | msgstr "" 42 | 43 | #: solr-for-wordpress.php:275 44 | msgid "...%s...
%s...
Couldn't locate the options page.
" 127 | msgstr "" 128 | 129 | #: solr-options-page.php:60 130 | msgid "Ping Success!" 131 | msgstr "" 132 | 133 | #: solr-options-page.php:64 134 | msgid "Ping Failed!" 135 | msgstr "" 136 | 137 | #: solr-options-page.php:70 138 | msgid "Pages Loaded!" 139 | msgstr "" 140 | 141 | #: solr-options-page.php:75 142 | msgid "Posts Loaded!" 143 | msgstr "" 144 | 145 | #: solr-options-page.php:80 146 | msgid "All Indexed Pages Deleted!" 147 | msgstr "" 148 | 149 | #: solr-options-page.php:86 150 | msgid "Solr For WordPress" 151 | msgstr "" 152 | 153 | #: solr-options-page.php:89 154 | msgid "Connection Information" 155 | msgstr "" 156 | 157 | #: solr-options-page.php:92 158 | msgid "Solr Host" 159 | msgstr "" 160 | 161 | #: solr-options-page.php:97 162 | msgid "Solr Port" 163 | msgstr "" 164 | 165 | #: solr-options-page.php:102 166 | msgid "Solr Path" 167 | msgstr "" 168 | 169 | #: solr-options-page.php:107 170 | msgid "Indexing Options" 171 | msgstr "" 172 | 173 | #: solr-options-page.php:110 174 | msgid "Index Pages" 175 | msgstr "" 176 | 177 | #: solr-options-page.php:112 178 | msgid "Index Posts" 179 | msgstr "" 180 | 181 | #: solr-options-page.php:117 182 | msgid "Remove Page on Delete" 183 | msgstr "" 184 | 185 | #: solr-options-page.php:119 186 | msgid "Remove Post on Delete" 187 | msgstr "" 188 | 189 | #: solr-options-page.php:124 190 | msgid "Remove Page on Status Change" 191 | msgstr "" 192 | 193 | #: solr-options-page.php:126 194 | msgid "Remove Post on Status Change" 195 | msgstr "" 196 | 197 | #: solr-options-page.php:131 198 | msgid "Excludes (comma-separated integer ids)" 199 | msgstr "" 200 | 201 | #: solr-options-page.php:136 202 | msgid "Result Options" 203 | msgstr "" 204 | 205 | #: solr-options-page.php:139 206 | msgid "Output Result Info" 207 | msgstr "" 208 | 209 | #: solr-options-page.php:141 210 | msgid "Output Result Pager" 211 | msgstr "" 212 | 213 | #: solr-options-page.php:146 214 | msgid "Output Facets" 215 | msgstr "" 216 | 217 | #: solr-options-page.php:148 218 | msgid "Category Facet as Taxonomy" 219 | msgstr "" 220 | 221 | #: solr-options-page.php:153 222 | msgid "Categories as Facet" 223 | msgstr "" 224 | 225 | #: solr-options-page.php:155 226 | msgid "Tags as Facet" 227 | msgstr "" 228 | 229 | #: solr-options-page.php:160 230 | msgid "Author as Facet" 231 | msgstr "" 232 | 233 | #: solr-options-page.php:162 234 | msgid "Type as Facet" 235 | msgstr "" 236 | 237 | #: solr-options-page.php:167 238 | msgid "Number of Results Per Page" 239 | msgstr "" 240 | 241 | #: solr-options-page.php:172 242 | msgid "Max Number of Tags to Display" 243 | msgstr "" 244 | 245 | #: solr-options-page.php:180 246 | msgid "Save Changes" 247 | msgstr "" 248 | 249 | #: solr-options-page.php:186 250 | msgid "Actions" 251 | msgstr "" 252 | 253 | #: solr-options-page.php:189 254 | msgid "Check Server Settings" 255 | msgstr "" 256 | 257 | #: solr-options-page.php:190 solr-options-page.php:195 258 | #: solr-options-page.php:200 solr-options-page.php:205 259 | msgid "Execute" 260 | msgstr "" 261 | 262 | #: solr-options-page.php:194 263 | msgid "Load All Pages" 264 | msgstr "" 265 | 266 | #: solr-options-page.php:199 267 | msgid "Load All Posts" 268 | msgstr "" 269 | 270 | #: solr-options-page.php:204 271 | msgid "Delete All" 272 | msgstr "" 273 | 274 | #. Plugin Name of an extension 275 | msgid "Solr for WordPress" 276 | msgstr "" 277 | 278 | #. Plugin URI of an extension 279 | msgid "https://launchpad.net/solr4wordpress" 280 | msgstr "" 281 | 282 | #. Description of an extension 283 | msgid "Indexes, removes, and updates documents in the Solr search engine." 284 | msgstr "" 285 | 286 | #. Author of an extension 287 | msgid "Matt Weber" 288 | msgstr "" 289 | 290 | #. Author URI of an extension 291 | msgid "http://www.mattweber.org" 292 | msgstr "" 293 | -------------------------------------------------------------------------------- /solr-options-page.php: -------------------------------------------------------------------------------- 1 | 'localhost','port'=>8983, 'path'=>'/solr'); 35 | $options['s4w_server']['info']['master']= array('host'=>'localhost','port'=>8983, 'path'=>'/solr'); 36 | $options['s4w_server']['type']['search'] = 'master'; 37 | $options['s4w_server']['type']['update'] = 'master'; 38 | 39 | //by default we index pages and posts, and remove them from index if there status changes. 40 | $options['s4w_content']['index'] = array('page'=>'1', 'post'=>'1'); 41 | $options['s4w_content']['delete'] = array('page'=>'1', 'post'=>'1'); 42 | $options['s4w_content']['private'] = array('page'=>'1', 'post'=>'1'); 43 | 44 | 45 | $options['s4w_index_pages'] = 1; 46 | $options['s4w_index_posts'] = 1; 47 | $options['s4w_delete_page'] = 1; 48 | $options['s4w_delete_post'] = 1; 49 | $options['s4w_private_page'] = 1; 50 | $options['s4w_private_post'] = 1; 51 | $options['s4w_output_info'] = 1; 52 | $options['s4w_output_pager'] = 1; 53 | $options['s4w_output_facets'] = 1; 54 | $options['s4w_exclude_pages'] = array(); 55 | $options['s4w_exclude_pages'] = ''; 56 | $options['s4w_num_results'] = 5; 57 | $options['s4w_cat_as_taxo'] = 1; 58 | $options['s4w_solr_initialized'] = 1; 59 | $options['s4w_max_display_tags'] = 10; 60 | $options['s4w_facet_on_categories'] = 1; 61 | $options['s4w_facet_on_taxonomy'] = 1; 62 | $options['s4w_facet_on_tags'] = 1; 63 | $options['s4w_facet_on_author'] = 1; 64 | $options['s4w_facet_on_type'] = 1; 65 | $options['s4w_enable_dym'] = 1; 66 | $options['s4w_index_comments'] = 1; 67 | $options['s4w_connect_type'] = 'solr'; 68 | $options['s4w_index_custom_fields'] = array(); 69 | $options['s4w_facet_on_custom_fields'] = array(); 70 | $options['s4w_index_custom_fields'] = ''; 71 | $options['s4w_facet_on_custom_fields'] = ''; 72 | 73 | 74 | //update existing settings from multiple option record to a single array 75 | //if old options exist, update to new system 76 | $delete_option_function = 'delete_option'; 77 | if (is_multisite()) { 78 | $indexall = get_site_option('s4w_index_all_sites'); 79 | $delete_option_function = 'delete_site_option'; 80 | } 81 | //find each of the old options function 82 | //update our new array and delete the record. 83 | foreach($options as $key => $value ) { 84 | if( $existing = get_option($key)) { 85 | $options[$key] = $existing; 86 | $indexall = FALSE; 87 | //run the appropriate delete options function 88 | $delete_option_function($key); 89 | } 90 | } 91 | 92 | $s4w_settings = $options; 93 | //save our options array 94 | s4w_update_option($options); 95 | } 96 | 97 | wp_reset_vars(array('action')); 98 | 99 | # save form settings if we get the update action 100 | # we do saving here instead of using options.php because we need to use 101 | # s4w_update_option instead of update option. 102 | # As it stands we have 27 options instead of making 27 insert calls (which is what update_options does) 103 | # Lets create an array of all our options and save it once. 104 | if ($_POST['action'] == 'update') { 105 | //lets loop through our setting fields $_POST['settings'] 106 | foreach ($s4w_settings as $option => $old_value ) { 107 | $value = $_POST['settings'][$option]; 108 | 109 | switch ($option) { 110 | case 's4w_solr_initialized': 111 | $value = trim($old_value); 112 | break; 113 | 114 | case 's4w_server': 115 | //remove empty server entries 116 | $s_value = &$value['info']; 117 | 118 | 119 | foreach ($s_value as $key => $v) { 120 | //lets rename the array_keys 121 | if(!$v['host']) unset($s_value[$key]); 122 | } 123 | break; 124 | } 125 | if ( !is_array($value) ) $value = trim($value); 126 | $value = stripslashes_deep($value); 127 | $s4w_settings[$option] = $value; 128 | } 129 | // if we are in single server mode set the server types to master 130 | // and configure the master server to the values of the single server 131 | if ($s4w_settings['s4w_connect_type'] =='solr_single'){ 132 | $s4w_settings['s4w_server']['info']['master']= $s4w_settings['s4w_server']['info']['single']; 133 | $s4w_settings['s4w_server']['type']['search'] = 'master'; 134 | $s4w_settings['s4w_server']['type']['update'] = 'master'; 135 | } 136 | // if this is a multi server setup we steal the master settings 137 | // and stuff them into the single server settings in case the user 138 | // decides to change it later 139 | else { 140 | $s4w_settings['s4w_server']['info']['single']= $s4w_settings['s4w_server']['info']['master']; 141 | } 142 | //lets save our options array 143 | s4w_update_option($s4w_settings); 144 | 145 | //we need to make call for the options again 146 | //as we need them to come out in an a sanitised format 147 | //otherwise fields that need to run s4w_filter_list2str will come up with nothin 148 | $s4w_settings = s4w_get_option('plugin_s4w_settings'); 149 | ?> 150 |Try again later?
For example, instead of searching for 'Apple iPhone 3.0 3GS', try something simple like 'iPhone'.
83 |