lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Attardi" <jatta...@gmail.com>
Subject Indexing/Analyzer question - case-insensitive "contains" search
Date Mon, 30 Jul 2007 13:56:41 GMT
Hi everyone,

I told you I'd be back with more questions!  :-)
Here is my situation. In my application, the field to be searched is
selected via a drop-down box. I want my searches to basically be "contains"
searches - I take what the user typed in, put a wildcard character at the
beginning and end, and put that in a WildcardQuery with the selected field.
In simple cases, this works great.

But, the StandardAnalyzer and SimpleAnalyzer is removing some characters I
need. For example, one of my objects has a name of "Joe's Devices". If I
search for "Joe's", it doesn't work, because the apostrophe is stripped out.
I tried using the KeywordAnalyzer, which keeps the string intact, but then
won't my searches be case-sensitive? This is easy to fix of course by
calling toLowerCase() on the text when it is indexed, but then later when
retrieved from the index to be displayed in the search results, "Joe's
Devices" is displayed as "joe's devices". Is there anything I can do here
short of putting two copies of the name in the document - one indexed/not
stored ("joe's devices"), and one stored/not indexed("Joe's Devices") ? Or
can I accomplish this case-insensitive "contains" search some other way -
would I have to write a custom Analyzer, or something?

Thanks in advance!

-- 
Joe Attardi
jattardi@gmail.com
http://thinksincode.blogspot.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message