[OPEN-ILS-DEV] Patron Search - minor enhancement.
Mike Rylander
mrylander at gmail.com
Wed May 4 14:09:48 EDT 2011
On Wed, May 4, 2011 at 1:32 PM, Mike Rylander <mrylander at gmail.com> wrote:
> On Wed, May 4, 2011 at 12:44 PM, Niles Ingalls
> <nilesi at zionsville.lib.in.us> wrote:
>> I'd like to submit this patch, which will improve patron phone search results (at least for my purposes).
>> This patch will do a match against digits only, when the search method is given a search string that only contains digits.
>> Results will be improved in cases situations where number validation is loose, or where you have some legacy records that weren't fully washed.
>>
>>
>
> A couple things: you'd need to create the index in the same way for it
> to be effective; you'd need to apply your "remove all non-numbers"
> regexp_replace to all uses; and, for the implementation below, you
> need to reverse the logic in the 'if' -- it says "if it's all digits,
> remove non-digits".
>
Little thinko on that last point -- it's doing what you want when what
you want is to match the normalization of the searched column to that
of the user input, IOW, make the column look like only digits if the
input was only digits. That's entirely reasonable, but would still
need another index. As to the need to apply the regexp_replace in all
uses (against the phone columns), if you had a second index then it
might be beneficial to use either, and when non-digits are in the
query, look for a raw, exact (right-trunc) match.
--miker
> That said, something like this could indeed be useful, but it needs to
> be systematic and implement a numbers-only index first.
>
>>
>> /openils/lib/perl5/OpenILS/Application/Storage/Publisher/actor.pm
>>
>> 666c666,670
>> < push @ps, "evergreen.lowercase($p) ~ ?";
>> ---
>>> if ($pv =~ /^\d+$/) {
>>> push @ps, "evergreen.lowercase(REGEXP_REPLACE($p, '[^0-9]', '', 'g')) ~ ?";
>>> } else {
>>> push @ps, "evergreen.lowercase($p) ~ ?";
>>> }
>>
>>
>
>
> --
> Mike Rylander
> | VP, Research and Design
> | Equinox Software, Inc. / Your Library's Guide to Open Source
> | phone: 1-877-OPEN-ILS (673-6457)
> | email: miker at esilibrary.com
> | web: http://www.esilibrary.com
>
--
Mike Rylander
| VP, Research and Design
| Equinox Software, Inc. / Your Library's Guide to Open Source
| phone: 1-877-OPEN-ILS (673-6457)
| email: miker at esilibrary.com
| web: http://www.esilibrary.com
More information about the Open-ils-dev
mailing list