Case Sensitive Index with options to do Case In-Sensitive search

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Case Sensitive Index with options to do Case In-Sensitive search

Nick D.
Hi all,

I see that by not including the CaseFolder in my PolyAnalyzer at index time, I can do case sensitive searches. Is there a way to do a case insensitive search on an index that was stored case sensitive?

Example:

Store this: "This is an Example of what a case Sensitive line would be"

Search for this: "Example"
Also search for this: "example"

And return the line stored for both searches.

I have a need to have the option to do case insensitive and case sensitive searches at search time and having 2 indexes (1 for each case) is not really an option due to the amount of live data (data constantly coming off the wire) being indexed at once.
Reply | Threaded
Open this post in threaded view
|

Re: [lucy-user] Case Sensitive Index with options to do Case In-Sensitive search

Nick Wellnhofer
On Jan 31, 2014, at 22:59 , Nick D. <[hidden email]> wrote:

> I see that by not including the CaseFolder in my PolyAnalyzer at index time,
> I can do case sensitive searches. Is there a way to do a case insensitive
> search on an index that was stored case sensitive?

Not really. You could write a custom query class, but it won’t be very efficient.

> I have a need to have the option to do case insensitive and case sensitive
> searches at search time and having 2 indexes (1 for each case) is not really
> an option due to the amount of live data (data constantly coming off the
> wire) being indexed at once.

You don’t have to create two separate indexes. You can create a single index with two fields. One for case-insensitive matching with a CaseFolder and another for case-sensitive matching without.

Nick


Reply | Threaded
Open this post in threaded view
|

Re: [lucy-user] Case Sensitive Index with options to do Case In-Sensitive search

Peter Karman
In reply to this post by Nick D.
On 1/31/14 3:59 PM, Nick D. wrote:

> Store this: "This is an Example of what a case Sensitive line would be"
>
> Search for this: "Example"
> Also search for this: "example"
>
> And return the line stored for both searches.
>
> I have a need to have the option to do case insensitive and case sensitive
> searches at search time and having 2 indexes (1 for each case) is not really
> an option due to the amount of live data (data constantly coming off the
> wire) being indexed at once.


Store the same text under two different fields in the same index, one
with an Analyzer w/CaseFolder (foo_lc) and one w/o (foo_cs).

Then your query parser can expand your query to an 'OR' search for both
fields. The alias_for feature in Search::Query::Parser could help:

  my $parser = Search::Query::Parser->new(
     dialect => 'Lucy',
     fields  => {
         foo => [qw( foo_lc foo_cs )],
     },
  );

https://metacpan.org/pod/Search::Query::Field#alias_for


--
Peter Karman  .  http://peknet.com/  .  [hidden email]