How do I.. Implement search?
  • I am developing a new site on my local vagrant box and when I simply append /search in the address box I would expect a search page to appear? But all I get is a white page.

    fuel/modules/search/views/search.php - I have already located this file and now wish to start styling the results, but with a white page I cannot go any further.
  • You can copy that file to fuel/applications/views/search.php and paste in the code from that fuel/modules/search/views/search.php into it so it allows you to update the search module codebase without affecting your custom changes. The default value in fuel/modules/search/config/search.php points to the fuel/application/views/search.php file.

    I would also copy over the fuel/modules/search/config/search.php to fuel/application/config/search.php if you haven't already and you can manipulate the search configuration values outside of the fuel/modules/search folder.
  • Also, have you indexed the site from the Search option in the Fuel Dashboard?
  • almostcompletely, is it meant to show Index removed: on every line?
  • It doesn't seem to create an index?
  • Make sure you've set up the search delimiters in the config to match something in your pages.
  • Okay, I have a search page present however it won't show any results, my delimiter is set to section id="main_inner" so it should be able to index something, but it does not? :/
  • Did you re-index in the admin and is it returning anything? You can also run it via the command line.
  • Correct, I am re-indexing via Admin. Going to run via the command line as suggested and report findings.
  • php index.php fuel/tools/search/index_site

    When I try and run this from the command line I get an error....

    Type: Error
    Message: Call to undefined function mysqli_init()
    Filename: /vagrant/html/local.fuel.co.uk/fuel/codeigniter/database/drivers/mysqli/mysqli_driver.php
    Line Number: 135

    So I tried changing to mysql inside fuel/config/database.php to see if that would make any difference which it didn't...

    Type: Error
    Message: Call to undefined function mysql_connect()
    Filename: /vagrant/html/local.fuel.co.uk/fuel/codeigniter/database/drivers/mysql/mysql_driver.php
    Line Number: 136
  • What version of PHP are you running via command line?

    But to confirm, you have a
    in your home pages HTML code that has content to be indexed? And when you run this in the admin, is there anything that gets returned?
  • PHP 7.1.9-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Sep 2 2017 06:19:21) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.9-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans

    ------

    When run through the admin this is what happens, I've cut it short.

    Index removed: 404_error
    Index removed: additional-driver-bonus-builder
    Index removed: awards
    Index removed: bike/get-bike-insurance
    Index removed: bike/motorbike-insurance
    Index removed: bike/retrieve-bike-insurance
    Index removed: bike/scooter-insurance
    Index removed: blog/2017/09/29/this-is-my-first-post
    Index removed: blog/authors/1
    Index removed: blog/authors/2
    Index removed: breakdown/membership
    Index removed: business/business-insurance
    Index removed: business/directors-insurance
    Index removed: business/hotel-insurance
    Index removed: business/landlord-insurance
    Index removed: business/professional-insurance
    Index removed: business/pub-insurance
    Index removed: business/restaurant-insurance
    Index removed: business/shop-insurance
    Index removed: business/surgery-insurance
    Index removed: business/takeaway-insurance
    Index removed: business/tradesmen-insurance
    Index removed: business/why-business-insurance
    Index removed: car/car-insurance
    Index removed: car/caravan-insurance
    .....
    .....
  • What do you have for your delimiter setting in your fuel/application/config/search.php:
    $config['search']['delimiters'] = array(
    '<div id="main">',
    '//meta[@name="keywords"]/@content',
    );


    For the command line issue, see this thread for some possible help:
    https://stackoverflow.com/questions/33612956/codeigniter-fatal-error-call-to-undefined-function-mysqli-init
  • Ok thanks for the command line link.

    $config['search']['delimiters'] = array(
    ' '//meta[@name="keywords"]/@content',
    );

    Every page has a section with id set to "main_inner"... with or without further attributes, e.g.
  • Try this:
    $config['search']['delimiters'] = array(
    '<section id="main_inner">',
    '//meta[@name="keywords"]/@content',
    );
  • Not sure why it pasted like it did above.. I have a slight variation on yours:

    $config['search']['delimiters'] = array(
    ' '//meta[@name="keywords"]/@content',
    );

    It's minus that closing > tag on the end of the 'section'.. neither work. :(
  • Oh right, the forum doesn't like me pasting that particular line of code into it.

    I can confirm I have section id="main_inner" as the first value of the $config array as per your code above.
  • It should include the closing ">" and uses the DOM & XPath to find that node. If you create a simple static view file called search_test.php page with the delimiter on, are you able to index that single page (will need to select that page explicitly in the re-index). The index won't save if there is empty content and/or empty title value for that page (see line 486 of Fuel_search.php)

    <html>
    <title>This is the title</title>
    <body>
    <section id="main_inner">
    THIS IS A TEST
    </section>
    </body>
    </html>
  • No such luck won't even index search_test.php...:(

    $config['nav']['tools']['tools/search'] = lang('module_search');
    $config['tables']['search'] = 'fuel_search';
    $config['search'] = array();
    $config['search']['base_url'] = '';
    $config['search']['indexing_enabled'] = TRUE;
    $config['search']['user_agent'] = 'FUEL';
    $config['search']['query_type'] = 'match boolean';
    $config['search']['delimiters'] = array(
    '<section id="main_inner">',
    '//meta[@name="keywords"]/@content',
    );
    $config['search']['title_tag'] = array('title', 'h1');
    $config['search']['preserve_title_html'] = FALSE; //set TRUE to keep HTML
    $config['search']['ignore_robots'] = FALSE; // set TRUE to ignore
    $config['search']['excerpt_tag'] = array('p', '//meta[@name="description"]/@content');
    $config['search']['language_tag'] = array('html[@lang]/@lang');
    $config['search']['exclude'] = array();
    $config['search']['index_method'] = 'AUTO';
    $config['search']['index_modules'] = TRUE;
    $config['search']['view'] = 'search';
    $config['search']['min_length_search'] = 3;
    $config['search']['depth'] = 0;
    $config['search']['use_tmp_table'] = FALSE;
    $config['search']['cleaning_funcs'] = array('zap_gremlins');
    $config['search']['pagination'] = array(
    'per_page' => 1a0,
    'num_links' => 2,
    'prev_link' => lang('search_prev_page'),
    'next_link' => lang('search_next_page'),
    'first_link' => lang('search_first_link'),
    'last_link' => lang('search_last_link'),
    );


    /* To allow users to modify under the settings section of the CMS, uncomment this area */
    //$config['search']['settings'] = array();
    /* $config['search']['settings']['user_agent'] = array(); */
    //$config['search']['settings']['delimiters'] = array('default' => '"main_inner"');
    //$config['search']['settings']['query_type'] = array('type' => 'select', 'options' => array('match' => 'match', 'match boolean' => 'match boolean', 'like' => 'like'));
  • deleted
  • Okay back on this again, no such luck with indexing the site.
  • Is there anything I can look at so that I can get this working?
  • I would look into the fuel/modules/search/Fuel_search::index_page since it appears to be returning FALSE and see where in that method it's failing.
  • scrape_page: url = http://local.fuel.co.uk/car/car-insurance just_header = parent =
    /vagrant/html/local.fuel.co.uk/fuel/modules/search/libraries/Fuel_search.php:672:
    array (size=8)
    10002 => string 'http://local.fuel.co.uk/car/car-insurance' (length=41)
    19913 => boolean true
    13 => int 20
    78 => int 10
    19914 => boolean true
    10018 => string 'FUEL' (length=4)
    42 => boolean false
    44 => boolean false
    Curl.php add_session() $url = http://local.fuel.co.uk/car/car-insurance
    Curl.php add_session() $opts ---> next line
    /vagrant/html/local.fuel.co.uk/fuel/modules/fuel/libraries/Curl.php:127:
    array (size=8)
    10002 => string 'http://local.fuel.co.uk/car/car-insurance' (length=41)
    19913 => boolean true
    13 => int 20
    78 => int 10
    19914 => boolean true
    10018 => string 'FUEL' (length=4)
    42 => boolean false
    44 => boolean false
    Curl.php add_session() $opt_params ---> next line
    /vagrant/html/local.fuel.co.uk/fuel/modules/fuel/libraries/Curl.php:129:
    array (size=0)
    empty
    noramlize the url = http://local.fuel.co.uk/car/car-insurance
    key = 0
    set_options $o -----> next line
    /vagrant/html/local.fuel.co.uk/fuel/modules/fuel/libraries/Curl.php:195:
    array (size=8)
    10002 => string 'http://local.fuel.co.uk/car/car-insurance' (length=41)
    19913 => boolean true
    13 => int 20
    78 => int 10
    19914 => boolean true
    10018 => string 'FUEL' (length=4)
    42 => boolean false
    44 => boolean false

    set_options $key ------> next line
    0
    Curl.php is_multi() = false - exec_single()
    $this->_output -----> next line
    /vagrant/html/local.fuel.co.uk/fuel/modules/fuel/libraries/Curl.php:274:boolean false

    $output = $this->CI->curl->exec(); ----> on next line
    /vagrant/html/local.fuel.co.uk/fuel/modules/search/libraries/Fuel_search.php:681:boolean false
    $this->CI->curl->error() -----> on next line
    /vagrant/html/local.fuel.co.uk/fuel/modules/search/libraries/Fuel_search.php:686:
    array (size=1)
    0 => string 'Could not resolve host: local.fuel.co.uk' (length=40)
    http_code = 0 - needs to be 200 - so not good
    html scrape:
    Index removed: car/car-insurance

    Looks like I am having a problem with Curl running through a vagrant box, attempting to resolve this one now - will try and report solution if its worthy of a mention.
  • Okay fixed now. Both Wget and Curl couldn't resolve to the local host.

    After some extensive googling I found that if I added the below line to my vagrantfile (near line 60) and perform a reload the box could now resolve to any local hosts defined in conf/options.txt.

    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!