Searching with a wildcard operator

Post Reply
gazim
Posts: 66
Joined: Sun Feb 18, 2001 1:01 pm

Searching with a wildcard operator

Post by gazim »

I am trying to run a sqlstring with a wildcard operator(*) in it. here's how my string looks like
<$strsql =
"select DOCID from tbldocB where (tbldocB.DOCID\BEGBATES\ENDBATES\BEGATTACH\ENDATTACH\PAGES\ATTPAGES\DOCDATE\ESTIMATED\DOCTYPE\DESCRIPTORS\SOURCE\PRODUCTION\SITE\TITLE\AUTHOR\ADDRESSEE\COPYEE\NAMES\KEYDOC\REVIEWDOC\ISSUECODES\ATTYNOTES\OTHERNAMES\CDVOL\DELDATE\LOADDATE\UPDATEDATE\OCR LIKE 'test*')"

<SQL MAX=50 $strsql>
<SQL>
I got this following error message.

<!-- 115 /oledbtest:210: Partially dropping term `test*' in query `test*': Max words per set exceeded -->

Then it displays the results.
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

Searching with a wildcard operator

Post by Kai »

This message indicates that the number of distinct words matched by that wildcard expression -- not the number of overall row hits -- exceeded the limit for words per set.

This limit is set to 500 by default so that queries with large numbers of words don't overload the machine, since a wildcard may match many words, each of which may match many rows, all of which may have to be ranked and sorted for the results. By dropping some of these words -- which may be typos anyway -- the query can return faster in potential overload situations.

The phrase "Partially dropping" means that some of the words matching "test*" were dropped for speed, but the ones considered most significant (the root word and English suffixes) were kept up to the limit.

See http://www.thunderstone.com/site/vortex ... qprot.html for more information on changing these limits.

As an aside, it is good practice to use parameters in <SQL> where possible, instead of literal strings (eg. $query instead of 'test*'). This saves the coding, processing time, potential errors and security risks associated with literal strings in <SQL> statements. See http://www.thunderstone.com/site/vortexman/node36.html for more info.
Post Reply