1

The tags API has a "filter" parameter but it only matches the exact substring in the parameter in the tags.

On Travel we have one kind of tags, IATA airport codes (SYD for Sydney, SFO for San Francisco, etc) which would match a pattern of having only three characters. But as each character can be any letter of the alphabet, the current filter doesn't help and we have to fetch all the tags and filter the three-letter ones externally.

Would there be enough other sites with tags matching some kind of pattern for something like this to be useful? As sites get quite large and have lots of tags this query will become more and more resource heavy so a filtered version would use less bandwidth but perhaps more CPU on the server end.

1

2 Answers 2

2

No, we won't be implementing this.

Not that I don't see a use case for it, but we'd never be able to accept and execute arbitrary regular expressions against the database. It'd just be far too easy cripple performance wise (we've done this accidentally plenty of times, and we don't have to worry about malicious actors on the dev team).

While we could pursue some other matching scheme of our devising, it'd be a lot less flexible by necessity and probably a lot less useful.

1

Perhaps a good approach would be to cache the entire list of tags on a site (there are only 770, or 25 pages worth on Travel.SE). You can then run them through a RegEx locally. Tags don't change very much so you could just refresh your list every week or so to keep it up to date.

You didn't specify a particular language / framework, but if you were using Stack.PHP, you could simply do:

$tags = array();

$response = API::Site('travel')->Tags()->Exec();
while($tag = $response->Fetch())
    $tags[] = $tag;

This would leave you with an array ($tags) that contains all of the tags on the site.

1
  • Yes I know 770 isn't a huge number but I'm interested in scaling for the future too. Travel has the potential to have a huge number of tags for destinations if it gets really popular. I'm just using JavaScript with jQuery for now, no Stack Exchange framework. My tools will hopefully be plain old web pages anybody can run in any browser. But they may also just stay my own toys. Dec 28, 2011 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .