Sometimes search fails and it only happens in a specific environment (like staging or development server). It is really hard to understand what's wrong unless you see what query is actually performed on the server and what results are returned back to you. Having an optional "query log" and "result log" modes will be a great help.

Hope to submit a patch soon

Related Documentation

https://www.drupal.org/node/2240049

Comments

lex0r created an issue. See original summary.

lex0r’s picture

StatusFileSize
new3.44 KB

Possible implementation attached.

drunken monkey’s picture

Status: Needs review » Needs work
Issue tags: +needs port to Drupal 8

Great idea, thanks! That could really help a lot of people debugging their problems. Really strange that no-one thought of this before …

There are just a few small problems with your patch, but other than that it already looks great:

  1. +++ b/includes/solr_connection.inc
    @@ -907,10 +907,18 @@ class SearchApiSolrConnection implements SearchApiSolrConnectionInterface {
    +    if ($this->options['log_query']) {
    +      watchdog('search_api_solr', $queryString, NULL, WATCHDOG_DEBUG);
    

    Here and in other places: please surround the array access with !empty(), otherwise people will receive PHP notices after upgrading, before re-saving the server.

  2. +++ b/includes/solr_connection.inc
    @@ -918,7 +926,27 @@ class SearchApiSolrConnection implements SearchApiSolrConnectionInterface {
    +   * Helper function which logs response.
    +   *
    +   * @param $response
    +   *   the response received from Solr.
    

    This needs a clean-up regarding the Drupal documentation standards.

In any case, thanks again for creating this issue!

lex0r’s picture

StatusFileSize
new3.69 KB

Hi @drunken-monkey,

please review the patch. Besides the fixes now it also logs facets (if the case).

lex0r’s picture

Status: Needs work » Needs review
drunken monkey’s picture

StatusFileSize
new5.18 KB
new5 KB

Looks good, thanks!
However, I now noted that watchdog() is used in a not-recommended way. I also rephrased the form field descriptions and had some other style cleanup. Please test/review and I can commit!

lex0r’s picture

Status: Needs review » Reviewed & tested by the community

I tested it locally and it works well.

drunken monkey’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: -needs port to Drupal 8

OK, committed.
Moving to D8 for porting.
Thanks again!

  • drunken monkey committed 796a2e4 on 7.x-1.x authored by lex0r
    Issue #2604322 by lex0r, drunken monkey: Added the option to log all...
janusman’s picture

Just thought I'd mention solr_devel module... although that module currently shows a request in a block instead of logging it to watchdog.

mkalkbrenner’s picture

Assigned: Unassigned » mkalkbrenner
mkalkbrenner’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new5.76 KB

  • mkalkbrenner committed 22c5a7c on 8.x-2.x
    Issue #2604322 by mkalkbrenner: Log query and results
    
mkalkbrenner’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

josephdpurcell’s picture

josephdpurcell’s picture

Issue summary: View changes
josephdpurcell’s picture

In case anyone else lands here, it's worth noting there is some documentation here: https://www.drupal.org/node/2240049. It includes a robust example of logging using Solarium events.