[Info-vax] Looking for some text search ideas

Paul Sture nospam at sture.ch
Fri Sep 26 20:08:58 EDT 2014


On 2014-09-26, Michael Moroney <moroney at world.std.spaamtrap.com> wrote:
> Bill Pedersen <pedersen at ccsscorp.com> writes:
>
>>A recent example was to search only for the leading letter of the 
>>string.  On match then check the character at the position of the last 
>>letter in desired srting for a match, if not match continue with 
>>comparison search for first letter of string at position after the last 
>>letter failed.  This has been shown to speed up the searches.
>
> I've seen that search, not quite like that but the location and value of
> the mismatch determined how many characters to skip.  More efficient with
> long search strings.  I believe NOTES uses that algorithm.

The implementation language and the size of the field(s) being searched
might determine the best method here, and it can be a tradeoff between
runtime and KISS programming.  To take a worst case example, the overhead
of a DCL loop proceeding up a string 1 byte at a time would outweigh the
advantage of Bill's method, using F$LOCATE on the whole string would be
much more efficient.

When I did this sort of thing in COBOL many moons ago I used calls to
STR$POSITION on the whole string (max 132 bytes) to keep the program
simple to develop and later maintain.  Sub 2 second response times were
however not required for that application.

> Anyway, to the OP, does the value being search appear anywhere or only
> as a portion of a key (your "head gasket" example) ?  If only in the key,
> can you make a parallel file with only the keys and search that smaller 
> file?

Reducing the amount of data to be chewed through on a search is always a
good idea.

Next question: If the search returns multiple results, do they need
ordering by for example the number of units sold, to reflect popular parts.
In the case of lawn mowers, it's probably seasonal, so look at preceding
year's figures?

One can get quite carried away with the possibilities here :-)

-- 
A quick recap of Thursday 25th September 2014:
http://pbs.twimg.com/media/ByZfyyXIQAAXTai.jpg
Happy Thursday!



More information about the Info-vax mailing list