Hi All,
Just a couple of things with my site search, I am having trouble getting the search results to pickup any and all keywords. For example, if keywords for a search result are listed in the keywords column of my db as 'one, two, three' a search query for 'one two' is fine but a search for 'one three' will not display the search result. Instead of treating the keywords seperately it is treating all keywords as a whole phrase.
How can I make the search results pickup any keyword regardless of order.
Secondly I'm having trouble getting the search results to display by keyword relevance, any help is greatly appreciated.
Thanks.
function search()
{
parent::Controller();
$this->load->model('Templating');
$this->load->model('Company');
}
function index()
{
$this->load->view('search');
}
function search_redirect()
{
if ($_POST['keyword'] == '') $_POST['keyword'] = 'Keyword';
redirect('search/showlist/'.
urlencode(underscore($_POST['location'])).'/'.
urlencode(underscore($_POST['category'])).'/'.
urlencode(underscore($_POST['keyword'])));
}
function showlist($location = 'any', $category = 'any', $keyword = 'keyword', $offset = '0')
{
/* get results */
$data['companies'] = $this->Company->search($keyword, $category, $location, $offset, $name);
/* paginate results */
$row = $data['companies']->row();
if($keyword == 'keyword' and $category=='any' ) {
$data['categoryList'] = $this->buildCategoryList($location);
}
elseif(isset($row->categoryId)) {
$categoryId = $row->categoryId;
$data['linkList'] = $this->buildRefineList($categoryId);
}
$this->load->library('pagination');
$config['base_url'] = site_url().'search/showlist/'.$location.'/'.$category.'/'.$keyword.'/';
$config['total_rows'] = $this->Company->total_companies;
$config['per_page'] = $this->Company->per_page;
$config['num_links'] = 3;
$config['uri_segment'] = $this->uri->total_segments();
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['logged_in'] = $this->session->userdata('logged_in');
$data['company_id'] = $this->session->userdata('company_id');
$data['search_category'] = $category;
$data['search_location'] = $location;
if ($this->session->userdata('admin') != ''){
$data['admin'] = $this->session->userdata('admin');
}
/* initialise template settings */
$center = 'center/list_companies';
$this->load->vars($data);
$this->Templating->show($center);
}