Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
1.1k views
in Q2A Core by
I want to search only in text of all the questions ? I do not want to search answers.

1 Answer

+1 vote
by

Your question is interesting. There will be many approaches. If you want to finely change the search process, it would be to add a new search module. However, it requires advanced skills to do this. I will introduce more simple ways.

Example by layer module (Recommended):

    function html() {
        if($this->template == 'search') {
            if(isset($this->content['q_list']['qs'])) {
                foreach($this->content['q_list']['qs'] as $key => $q) {
                    if(isset($q['raw']['matchparts'])) {
                        if(substr($q['raw']['matchparts'], 0, 1) != 'Q')
                            unset($this->content['q_list']['qs'][$key]);
                    }
                }
            }
        }
        qa_html_theme_base::html();
    }

Example of core hack: qa-include/qa-app-search.php (around L94 for Q2A V1.6.3)

Before:

    //    Supplement the results as appropriate
    
        foreach ($results as $key => $result) {

After:

    //    Supplement the results as appropriate
    
        foreach ($results as $key => $result) {
            if (isset($result['match_type'])) {
                if($result['match_type'] != 'Q')
                    $result = null;
            }

Other, there will be method to create search index only question.

...