diff --git a/faqs.pl b/faqs.pl
index 67d706673da80a17b9ad8738ceca810baa8c73da..719f3c0b1707fd16a96b4ff916059e6b276fbc37 100755
--- a/faqs.pl
+++ b/faqs.pl
@@ -63,12 +63,12 @@ push @return, sprintf("## %s", @$_[1]);
my @tags = $dbh->selectall_array("SELECT id, name FROM tags t LEFT JOIN tags_questions tq ON tq.t_id = t.id WHERE tq.q_id = @$_[0];");
if ( scalar @tags ) {
- push @return, ('', 'Tags:');
+ push @return, ('', '### Tags');
foreach (@tags) {
push @return, sprintf("=> ./faqs.pl?tag=%d %s", @$_[0], @$_[1]);
}
}
- push @return, ('', @$_[2], '');
+ push @return, ('', '### Answer', @$_[2], '');
}
}
$dbh->disconnect();
diff --git a/search.pl b/search.pl
index 2428f41ab3d990e60c136db035ba4ecf76a19847..a343cc7c78083f0a9838b779a2377c35bc81d667 100755
--- a/search.pl
+++ b/search.pl
@@ -24,7 +24,7 @@
my $query = lc(uri_unescape($ENV{'QUERY_STRING'}));
if ($query eq '' || $query !~ /^[0-9a-z\s]*$/i)
{
- write_response('INPUT', 'Search faqs for the following terms (separate by blank)', undef);
+ write_response('INPUT', 'Search faqs for the following terms (separate by blank, all terms must match)', undef);
}
my @body = ();
@@ -42,8 +42,9 @@ my ($term) = @_;
my @result = ();
my $dbh = DBI->connect($CONF{'dsn'}, '', '', { RaiseError => 1 }) or die $DBI::errstr;
- my @matchingtags = $dbh->selectall_array("SELECT DISTINCT t.*, count(tq.q_id) AS count FROM fts_data INNER JOIN tags t ON t.id = fts_data.t_id LEFT JOIN tags_questions tq ON tq.t_id = t.id WHERE fts_data MATCH '\"text\": \"$term\"' GROUP BY t.id ORDER BY rank");
- my @matchingfaqs = $dbh->selectall_array("SELECT DISTINCT q_id, q.question FROM fts_data INNER JOIN questions q ON q.id = q_id WHERE fts_data MATCH '\"text\": \"$term\"' ORDER BY rank;");
+ my $fts_search = join(' AND ', split(/ /, $term));
+ my @matchingtags = $dbh->selectall_array("SELECT DISTINCT t.*, count(tq.q_id) AS count FROM fts_data INNER JOIN tags t ON t.id = fts_data.t_id LEFT JOIN tags_questions tq ON tq.t_id = t.id WHERE fts_data MATCH '$fts_search' GROUP BY t.id ORDER BY rank");
+ my @matchingfaqs = $dbh->selectall_array("SELECT DISTINCT q_id, q.question FROM fts_data INNER JOIN questions q ON q.id = q_id WHERE fts_data MATCH '$fts_search' ORDER BY rank;");
$dbh->disconnect();
if ( !scalar @matchingtags && !scalar @matchingfaqs) {