Re: Substring query

From: James Avery <avery_at_wapmore.com>
Date: Fri, 16 Feb 2001 14:36:25 +0100
Message-ID: <3A8D2CD9.9B1C07A0_at_wapmore.com>


BP Margolin wrote:
>
> James,
>
> Would it be possible for you to post some sample data, and the results you
> are looking for using that sample data?
>
> Perhaps it's just me, but I really can't make heads or tails out of what you
> are requesting. Remember that you know your data and application, but we
> don't, so examples are frequently very helpful in explaining a problem.

I'm sorry if I didn't make sense. Here is an explanation of the problem using more words.

The specific case in question goes thus:

When given an URL, it may contain CGI-variables - some of which contribute to deciding the nature of the content that is returned (e.g. "function=weather"), and some of which are irrelevant (e.g. "usrid=..." or similar).

Similarly, an URL may have parts that are generated based on e.g. the current date or on a previous CGI query.

The task at hand is to bind some information to a "logical" resource, or in other words, a class of URLs that in some way are equivalent - and to look up this information using an instance of that class.

For example: foo.org has a weather forecast that, given the date as parameters, tells you how the weather will be. When you log in, you choose your language, and a full instance of an URL might be   

   "http://www.foo.org/bar/Chinese/weather.php?month=2&day=3" or "http://www.foo.org/bar/Dansk/weather.php?day=28&month=12&year=2002".

Using either of these URLs as a query string for a lookup should give the same result.
In this case, the requirement could be that the query string match the pattern defined by the
regular expression:  

/^http\:\/\/(www\.)?foo\.org\/bar\/([^\/]+)\/weather.php\?((month|day|year)\=[^\&]*)+/

So to reiterate the original question, what I am looking for is something that will allow me
to write

 lookupA(s) = the set of entries such that s matches the pattern defined by the entrys' key

or  

 lookupB(s) = the set of entries such that the entrys' key is a substring of s

If the first case is possible then we are done.

In the second case, the database would have entries containing tuples on the form

 "foo.org/bar"
   =>
(/^http\:\/\/(www\.)?foo\.org\/bar\/[^\/]+\/weather.php\?((day|month|year)\=[^\&]*)+/,

       Info_for_weather)
 "foo.org" => (/^http\:\/\/(www\.)?foo\.org\/[^\/]+\/index\.html/, other_info)
  ...etc.

lookupB(), using one of the two exaple-urls as the argument, would return both of the entries above, since both entries' keys are substrings of the query string, and one could check against the regular expressions in turn and find that only the first entry matches.

I hope this makes my question clearer.

Thanks in advance.

-- 
  Med venlig hilsen,
    James Avery <avery_at_wapmore.com>
Received on Fri Feb 16 2001 - 14:36:25 CET

Original text of this message