• Hi, been fiddeling a bit with this plugin for our custom solr search.
    The plugin almost got all we need, if we just add in some small code changes I think we can use it perfectly.

    Im using the current stable for this.

    Our search form got more than just the text input with name=”s”.
    This will mess up the detection in function mss_template_redirect (line 546-547) as the “s=” part of the querystring will come after some other parameters instead of first and the code below will not detect it as the “?” will be missing.

    $search = stripos($_SERVER['REQUEST_URI'], '?s=');
    $autocomplete = stripos($_SERVER['REQUEST_URI'], '?method=autocomplete');

    If we replace it with this bit of code it will find it in any case.

    $qs = substr($_SERVER['REQUEST_URI'], 2);
    parse_str($qs, $qs_parsed);
    $search = isset($qs_parsed['s']);
    $autocomplete = $qs_parsed['method'] == 'autocomplete';

    The next part is that we need to change some params sent to solr based on our extra inputs in the search form.
    If we add this line in file advanced-search-by-my-solr-server.inc.php

    $params = apply_filters('mss_query_params', $params);

    inside the function mss_query() right before this code

    $response = $solr->search($qry, $offset, $count, $params);

    We have the possibility to alter the params in our theme functions.php easily with.

    function fiddle_query_params($params) {
      var_dump($_REQUEST);
      // Set params to our needs!
      return $params;
    }
    add_filter('mss_query_params', 'fiddle_query_params');

    This procedure can be repeated with function mss_autocomplete()

    $params = apply_filters('mss_autocomplete_params', $params);
    $response = $solr->search($q, 0, $limit, $params);

    And in our themes functions.php

    add_filter('mss_autocomplete_params', 'fiddle_autocomplete_params');
    
    function fiddle_autocomplete_params($params) {
      var_dump($_REQUEST);
       // Set params to our needs!
      return $params;
    }

    So what do you think?
    I have not put this to any real test yet and i might have missed out of something but at a first glance it seems to me that theese small changes will expand the plugins functionality pretty much as you can utilize the SolrPhpClient even more.

    http://wordpress.org/plugins/advanced-search-by-my-solr-server/

  • The topic ‘Suggestion improvement’ is closed to new replies.