Home | About | Sematext search-lucene.com search-hadoop.com
 Search Lucene and all its subprojects:

Switch to Plain View
Lucene, mail # user - Wildcard and Literal Searches combined


+
mick l 2008-06-24, 12:28
+
Jon Loken 2008-06-24, 12:51
+
mick l 2008-06-24, 13:21
+
Jon Loken 2008-06-24, 13:33
Copy link to this message
-
Re: Wildcard and Literal Searches combined
Chris Hostetter 2008-06-25, 21:21

: My users require wildcard searches. Sometimes their search phrases contain
: spaces. I am having trouble trying to implement a wildcard search on strings
: containing spaces, so if the term includes spaces I force a literal search
: by adding double quotes to the search term.
: So the search string for 'Dublin' becomes search term (Dublin*)
: whereas search string 'Dublin City' becomes ("Dublin City")

: If I use (Dublin City*) I get all instances of Dublin OR City in the results
: which is not what I am looking for.

my naive understanding of your problem makes me think you should
completely avoid using the QueryParser.  Index this field as "UNTOKENIZED"
(or using an Analyzer that does no tokenization, but perhaps lowercases if
that's what you want) and at query time construct a WildCardQuery directly
off of the users input (lowercases first if that what you did at index
time)

...but i could be missunderstanding your goal.
-Hoss
---------------------------------------------------------------------
+
Erick Erickson 2008-06-24, 13:36