/** * Test a combination database and content search * */ function testComboSearch() { $results = processSearchExpression('(GeneralText contains "abcde") AND (Title contains "Test987")'); $this->assertTrue(count($results) == 1); $this->assertTrue($results[0]['filename'] == 'Test987.txt'); }
/** * This method runs the saved search bsed on the id of the saved search * * @author KnowledgeTree Team * @access public * @param integer $searchID The id of the saved search * @return array|object $results SUCCESS - The results of the saved serach | FAILURE - a pear error object */ public function run_saved_search($searchID) { $search = $this->get_saved_search($searchID); if (is_null($search) || PEAR::isError($search)) { $results = new PEAR_Error('Invalid saved search'); return $results; } $query = $search[0]['expression']; $results = processSearchExpression($query); return $results; }
/** * This is the search interface * * @param string $session_id * @param string $query * @param string $options * @return kt_search_response */ function search($session_id, $query, $options) { $this->debug("search('{$session_id}','{$query}','{$options}')"); $kt =& $this->get_ktapi($session_id); if (is_array($kt)) { return new SOAP_Value('return', "{urn:{$this->namespace}}kt_search_response", $kt); } $response = KTWebService::_status(KTWS_ERR_PROBLEM); $response['hits'] = array(); if (!defined('HAS_SEARCH_FUNCTIONALITY')) { $response['message'] = _kt('Search has not been implemented for this version of KnowledgeTree'); return new SOAP_Value('return', "{urn:{$this->namespace}}kt_search_response", $response); } $results = processSearchExpression($query); if (PEAR::isError($results)) { $response['message'] = _kt('Could not process query.') . $results->getMessage(); $results = array(); } else { foreach ($results as $key => $item) { $results[$key] = new SOAP_Value('item', "{urn:{$this->namespace}}kt_search_result_item", $item); } $response['message'] = ''; $response['status_code'] = KTWS_SUCCESS; } $response['hits'] = new SOAP_Value('hits', "{urn:{$this->namespace}}kt_search_results", $results); return new SOAP_Value('return', "{urn:{$this->namespace}}kt_search_response", $response); }
function search($arr) { $kt =& $this->KT; $listing = processSearchExpression("(GeneralText contains \"" . $arr['query'] . "\")"); $result = $this->_processListing($listing, 'search', $arr); if (!count($result)) { $result[] = array('text' => $this->xlate("No results found"), 'id' => ($listing[$i]['item_type'] == 'F' ? $listing[$i]['item_type'] . "_" : "") . $listing[$i]['id'], 'leaf' => true, 'relevance' => 0, 'qtip' => $this->xlate("Please retry your search")); } else { $result = array_slice($result, 0, 200); } //$this->setResponse($result); $this->setResponse(array('totalCount' => count($listing), 'items' => $result)); return true; }