Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.2k views
in Q2A Core by
edited by

Is there a point system or weight value assigned to Questions, Tags and answers when searching by a keyword?

I was curious how the Search within my Q&A operates, or how it evaluates order. I was assuming:
(from a single-word search)

Search evaluates: Tags, Questions then answer...or a score? For example

Tag 1pt
Question 1pt
Answer 1pt

Finding the keyword in the question once, but the answer 3 times is a score of 4.
Finding the keyword in a questions once, tag once and answer 2 times is a score of 4.

If that's true, how does it order them. I noticed that a keyword I used was found in an assumingly unexpected order (as search results) as follows:

Searched keyword resulted in six questions with the keyword I searched for:
Q1. Tag (1), Answer(3)
Q2. Question (1), Tag(1)
Q3. Question (1), Tag(1), Answer(1)
Q4. Answer(1)
Q5. Answer (2)

I don't see relevance, should it be order be Questions: 1, 3, 2, 5 and 4 at best? The reasoning behind this order is that described below, a tag should have a higher point or weight over the search word in questions, then answers.

Is there a way I can add more "points" or weight to each, question, tag and answer. For example, I'd want the tags to be a point or weight value of 3, questions of 2 and answer of 1 when searching keywords. Over time I think this would help users think about their tags more carefully and determine the best suitable keywords.

If I'm completely wrong, I'll change this question so not to confuse others.

Thank you.

Update:
I just wanted to add I did view Related questions and found this, but it was from 2011 and others that remain unanswered.

Q2A version: 1.7.4

1 Answer

+3 votes
by
selected by
 
Best answer

Is there a point system or weight value assigned to Questions, Tags and answers when searching by a keyword?

Yes

Tags, Questions then answer...or a score?

Evaluates different aspects, such as title words (for Q only), content words (for Q, A, C), tag words (for Q only) and the handle of the users. Also the hotness too. All the matches are weighted differently, even for same words matching different questions will generate different scoring because the id of the questions is used while weighting. Besides, if the word is too common, then it won't be considered.

Regarding the specific weight applied to content words it is Q = 1, A = 0.5 and C = 0.25 (I think NOTEs are matched to at 0.25) but the relationship to get the scoring is not simply linear as you suggested as the formulae are slightly more complex.

If that's true, how does it order them?

Once all scores of the different aspects (titles, content, tags, handles) are calculated they are summed up and joined to the relevant questions (lists only display questions, not answers or comments but can link to them). In this step also hotness is taken into consideration and, again, the question ID (the higher, which means the more recent, the better). Sorting is descendant by score.

I don't see relevance, should it be order be Questions: 1, 3, 2, 5 and 4 at best?

It is impossible to know because you should evaluate all aspects and you are missing handles, post ids, hotness and have even merged the title and content aspects.

Is there a way I can add more "points" or weight to each, question, tag and answer?

Yes. Check here (code linked to v1.7.4): https://github.com/q2a/question2answer/blob/4fce0eb2390f56b645dad375d1d81e9f91a97e69/qa-include/db/selects.php#L712

Look for all the mentions to "score" (usually near to a logarithm). Just update the query in that point.

by
Gosh, I've just seen this: http://www.question2answer.org/qa/2058/usage-and-regularity-of-the-search-box?show=2059#a2059

So it was all explained in there...
by
Wow...excellent info, thank you.  I'm going to edit as I explained to give slightly more weight on the Q, A and C's.  Thanks again!  I'll update this comment when I get things set.
...