Tag searching not reliable
Submitted bfarber, Aug 16 2012 09:27 AM | Last updated Sep 06 2012 07:43 AM
Searching by tags (whether just tags, or tags + search string) will not always reliably produce recent results as you might expect. To duplicate the issue we have to assume the following
The query to retrieve the tags will pull the first 250 tags that match the request ordered by tag id DESC
However, in this case, the OLDEST topics will have the HIGHEST tag_id. Even if we sorted by tag_added, if you were going back and retroactively editing topics to add tags, the oldest topics would have the newest tag_added date.
Then we take the tag ids and pull topic ids ordered by last_post descending - that's fine, however we've pulled all old tag results topic ids in the first place, so all of the results will be old and not the most recent, as you would expect.
See ticket 813010 if you need a reproducible example.
- The site has a lot of tags - well more than the 250 hardcoded limit
- The site has not tagged topics "in order". Assume, for instance, a site converts to or upgrades to IPB 3x and then starts retroactively tagging topics, probably newest to oldest.
The query to retrieve the tags will pull the first 250 tags that match the request ordered by tag id DESC
SELECT tg.* FROM ibf_core_tags tg WHERE tg.tag_meta_parent_id IN (xyz) AND tg.tag_meta_app='forums' AND tg.tag_meta_area='topics' AND tg.tag_text IN ('windows') AND tg.tag_aai_lookup IN (SELECT tag_perm_aai_lookup FROM ibf_core_tags_perms WHERE ( ( FIND_IN_SET(4,tag_perm_text) ) OR ( tag_perm_text='*' ) ) AND tag_perm_visible=1 ) ORDER BY tg.tag_id desc LIMIT 0,250However, in this case, the OLDEST topics will have the HIGHEST tag_id. Even if we sorted by tag_added, if you were going back and retroactively editing topics to add tags, the oldest topics would have the newest tag_added date.
Then we take the tag ids and pull topic ids ordered by last_post descending - that's fine, however we've pulled all old tag results topic ids in the first place, so all of the results will be old and not the most recent, as you would expect.
See ticket 813010 if you need a reproducible example.
| Status: | Fixed |
| Version: | 3.3.4 |
| Fixed In: | 3.4.0 |











4 Comments
-
I do not envy you.
If you use the date filtering options in advanced search and only perform a search for tags, the date filters are not honored.
Updating Status to: Fixed
Think I got this with little pain in the end