Actually, it doesn't seem to be all that hard. I copied the /qa-include/qa-page-search.php file and then used the code pasted below.
require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'qa-app-cookies.php';
require_once QA_INCLUDE_DIR.'qa-app-format.php';
// Perform the search if appropriate
if (strlen(qa_get('q'))) {
require_once QA_INCLUDE_DIR.'qa-db-selects.php';
require_once QA_INCLUDE_DIR.'qa-util-string.php';
$inquery=trim(qa_get('q'));
$words=qa_string_to_words($inquery);
$retrieve=2*QA_DB_RETRIEVE_QS_AS+1; // get enough results to be able to give some idea of how many pages of search results there are
//ADDED BY NATHAN
$qa_login_userid=qa_get_logged_in_userid();
$qa_start=min(max(0, (int)qa_get('start')), QA_MAX_LIMIT_START);
$qa_cookieid=qa_cookie_get();
//END ADDED BY NATHAN
$questions=qa_db_select_with_pending(
qa_db_search_posts_selectspec($qa_login_userid, $words, $words, $words, $words, $inquery, $qa_start, false, $retrieve)
);
$pagesize=qa_opt('page_size_search');
$gotcount=count($questions);
$questions=array_slice($questions, 0, $pagesize);
$usershtml=qa_userids_handles_html($questions);
qa_report_event('ajax_search', $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, array(
'query' => $inquery,
'start' => $qa_start,
));
echo json_encode($questions);
}
I also had to add a "search" case to the switch statement in qa-include/qa-ajax.php
case 'search':
require QA_INCLUDE_DIR.'qa-ajax-search.php';
break;
To allow browser-based testing I also allowed a few variables to be read from the $_REQUEST array instead of the $_POST array.
With those changes done, you can point your browser to
YOURDOMAIN/qa/index.php?qa=ajax&qa_operation=search&q=searchQuery
And you'll get JSON-encoded search results