createAnalysisField(); $query->setShowMatch(true); $query->setFieldName('cat,title'); $query->setFieldType('text_general'); $query->setFieldValue('Apple 60 GB iPod with Video Playback Black'); $query->setQuery('ipod'); // this executes the query and returns the result $results = $client->analyze($query); // show the results foreach ($results as $result) { echo '

Result list: ' . $result->getName() . '

'; foreach ($result as $item) { echo '

Item: ' . $item->getName() . '

'; $indexAnalysis = $item->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 = $item->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();