createAnalysisDocument(); $query->setShowMatch(true); $query->setQuery('ipod'); $doc = new Solarium_Document_ReadWrite( array( 'id' => 'MA147LL', 'name' => 'Apple 60 GB iPod with Video Playback Black', 'manu' => 'Apple Computer Inc.', 'cat' => 'electronics', 'cat' => 'music', 'features' => 'iTunes, Podcasts, Audiobooks', 'features' => 'Stores up to 15,000 songs, 25,000 photos, or 150 hours of video', 'features' => '2.5-inch, 320x240 color TFT LCD display with LED backlight', 'features' => 'Up to 20 hours of battery life', 'features' => 'Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video', 'features' => 'Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication', 'includes' => 'earbud headphones, USB cable', 'weight' => 5.5, 'price' => 399.00, 'popularity' => 10, 'inStock' => true, ) ); $query->addDocument($doc); // this executes the query and returns the result $result = $client->analyze($query); // show the results foreach ($result as $document) { echo '

Document: ' . $document->getName() . '

'; foreach ($document as $field) { echo '

Field: ' . $field->getName() . '

'; $indexAnalysis = $field->getIndexAnalysis(); if (!empty($indexAnalysis)) { echo '

Index Analysis

'; foreach ($indexAnalysis as $classes) { echo '
'.$classes->getName().'
'; foreach($classes as $result) { echo 'Text: ' . $result->getText() . '
'; echo 'Raw text: ' . $result->getRawText() . '
'; echo 'Start: ' . $result->getStart() . '
'; echo 'End: ' . $result->getEnd() . '
'; echo 'Position: ' . $result->getPosition() . '
'; echo 'Position history: ' . implode(', ',$result->getPositionHistory()) . '
'; echo 'Type: ' . htmlspecialchars($result->getType()) . '
'; echo 'Match: ' . var_export($result->getMatch(),true) . '
'; echo '-----------
'; } } } $queryAnalysis = $field->getQueryAnalysis(); if (!empty($queryAnalysis)) { echo '

Query Analysis

'; foreach ($queryAnalysis as $classes) { echo '
'.$classes->getName().'
'; foreach($classes as $result) { echo 'Text: ' . $result->getText() . '
'; echo 'Raw text: ' . $result->getRawText() . '
'; echo 'Start: ' . $result->getStart() . '
'; echo 'End: ' . $result->getEnd() . '
'; echo 'Position: ' . $result->getPosition() . '
'; echo 'Position history: ' . implode(', ',$result->getPositionHistory()) . '
'; echo 'Type: ' . htmlspecialchars($result->getType()) . '
'; echo 'Match: ' . var_export($result->getMatch(),true) . '
'; echo '-----------
'; } } } } } htmlFooter();