Viewing the padre command run when a search is input via the modern UI

Managed by | Updated .


Funnelback provides a number of ways for a query to be modified between when a user types in a query to when it's submitted to the query processor.

It can sometimes become confusing when a query isn't returning the expected results and being able to see the actual raw command run by padre-sw is desirable.

This article shows how the command can be intercepted and logged by writing a wrapper script for the padre-sw binary.


Step 1. Create a wrapper script

Log in to the Funnelback server and create a perl script containing the following code. Save the file as $SEARCH_HOME/bin/

#!/usr/bin/perl -w
use strict;
unshift(@ARGV, "padre-sw");
open (LOG, ">>", "/tmp/logi_cli.log");
for my $key (keys(%ENV)) {
    print LOG "export ".$key."='".$ENV{$key}."'\n";
print LOG $ARGV[0];
for (my $count = 1; $count < $#ARGV + 1; $count++) {
    my $arg = $ARGV[$count];
    $arg =~ s/\\/\\\\/g;
    $arg =~ s/"/\\"/g;
    print LOG " \"".$arg."\"";
close (LOG);

Step 2. Make the script executable

Make the script executable (and ensure that the file has the correct ownership and group settings - the same as for the padre-sw binary).

Step 3. Change the padre-sw binary

Edit the collection.cfg for the collection that needs testing. Add/edit the following setting:

Check that queries are still processed correctly by running a search against the collection.

Queries should now be logged to /tmp/log_cli.log and will include messages similar to:

export REQUEST_URI='/s/search.html'
export REMOTE_ADDR=''
export SEARCH_HOME='/opt/funnelback'
export HTTP_HOST='search-internal'
export QUERY_STRING='collection=all&profile=_default&query=dot'
/opt/funnelback/bin/padre-sw "-rmcf=FTaVMCGf" "-count_dates=d" "-QL=1" "-QL_rank=1" "-qlog_file=/opt/funnelback/data/all/live/log/queries-search-internal.log"

Don't forget to revert the collection.cfg change once you've finished testing by removing the line from the collection.cfg.

Was this artcle helpful?