Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Type-ahead tag matching does not work for all tags

0 votes
asked Apr 17, 2012 in Q2A Core by Merkus
edited May 13, 2012 by Merkus

I had originally set my site up with the default for hyphenated tags, and it was set like this for the first few weeks.

I then enabled the Use comma as the only tag separator option and the Q2A tag suggestion no longer works. It will only match one-word tags up to the space or hyphen.

This behavior does not occur on a Q2A site set up from the beginning to use comma as tag separator.


EDIT: I am editing this question because the issue ended up being different from what it appeared. The issue is that Q2A is returning just the 200 most popular tags, so if the user is entering a tag that is not in that list of 200 it will not find a match. My explanation is below.



commented Apr 19, 2012 by gidgreen
Thanks - can you post a more detailed example of the words you mean, so I can try to reproduce it here?
commented Apr 19, 2012 by Merkus
@gidgreen When Q2A is set to use hyphenated tages, these are stored in the words table in their hyphenated form. When Q2A is then changed to use comma separated tags, the hyphenated versions of these tags are already in the words table.

In other words, using Q2A default setup, enter a tag "foo-bar". Then change Q2A use use comma separated tags and enter a tag "foo bar". The words table will contain "foo-bar" which will not match "foo bar". Also, when typing "foo" into the tags field, tag matching will not suggest "foo-bar".

I hope this explanation makes sense. :)

2 Answers

+1 vote
answered May 13, 2012 by Merkus


Hope this helps: The tag-matching was not 'broken' by the switch. What is happening is that QA_DB_RETRIEVE_TAGS is set to 200 and qa_db_popular_tags_selectspec() is using this value, so only the 'most popular' 200 tags are returned for matching. My db has over 4,000 tags that have been used 5 times or more. I realize this is unusual, but others will likely encounter the 200 limit.
Ideally the tag list would be retrieved via ajax after the editor loads, or matching tags retrieved on the keyup event, but I understand this is not a high priority.
I will try to edit my question so that anybody else having this problem can find it.
0 votes
answered Sep 11, 2012 by gidgreen

I'm reviewing this issue now for Q2A 1.5.3 and have found the exact problem.

The function qa_db_popular_tags_selectspec(...) is applying a maximum of QA_DB_RETRIEVE_TAGS (default 200) to the number of tags retrieved, even though there is a different constant QA_DB_RETRIEVE_COMPLETE_TAGS (default 10000) that is supposed to determine how many tags are retrieved for auto completion on the page. The solution is to change the first line of that function to:

$count=isset($count) ? $count : QA_DB_RETRIEVE_TAGS;

commented Sep 11, 2012 by gidgreen
Actually 10000 is really a lot, so I'm changing the default value of QA_DB_RETRIEVE_COMPLETE_TAGS to 1000 in Q2A 1.5.3. You can set your own value for this constant in qa-config.php and it will override the default.