Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Q2A Core by
As an example, when I do a "Search" on the word "spam" and when I "Ask a question" entering just the word "spam", the search results are slightly different from the proposed answers in "Ask a question" but I don't know why.

Furthermore, I can't figure out what is the logic behind the order of the results in both cases. Doesn't seem to be based on anything obvious like date, votes, views, etc. I presume some measure of "relevancy" is used? If so, is it based on the number of time the searched/asked word(s) appear in the answer?
I think when asking questions it prioritises titles but I'm not 100% sure.
@Scott" per your own question about the "Related questions" side bar at http://www.question2answer.org/qa/15677/difference-between-related-questions-sidebar-asking-question, that indeed seems to be the case. Interested to know if "Search" and "Related questions" are based on the same logic as each other, and what's the thinking behind having these work differently from "Ask a question" suggested answers.

1 Answer

+2 votes

There is no straightforward answer to this since the ranking algorithm in each case is fairly complex, combining several factors.

I recommend looking at the comments in qa_db_search_posts_selectspec(...)  and qa_db_related_qs_selectspec(...) in qa-db-selects.php, or for the really definitive answer, at the SQL that these functions build.

Actually what I'm trying to get at is not the technical underpinning but rather the actual human reason for having different results in "Ask a question" suggestions vs. "Search" (I presume "Related Questions" is the same as one of these, presumably Search, rather than yet a third algorithm).

For example, is there some particular reason you think users would want to see different information in ask a question suggested questions vs. search results vs. related questions suggestions?
When asking a question, the search is based on matching words in the title only, since this is what the user has entered. For general search, the words are matched in content, tags, usernames, etc... since the text entered isn't specifically a question title. You could debate whether this is the appropriate behavior - easy to change in qa-ajax-asktitle.php if you think not. As for related questions, it uses a different form of ranking, based on commonalities between questions, including the category.
+1 for using the "general search algorithm" for "related questions" search.

A lot of user questions are already answered but not shown in related questions as the titles of the questions do not match. The general search algorithm could help to find even more matches.

@gidgreen: "easy to change in qa-ajax-asktitle.php" ... I will have a look soon...