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.

Is there any way I can combine the wildcard search and the literal?

Heres my existing code. Its in c# with Lucene.Net

//if input has spaces we do a literal search
if (sSearchQuery.IndexOf(" ") < 0)
sSearchQuery = "(" + sSearchQuery + "*)";
sSearchQuery = "(\"" + sSearchQuery + "\")";
IndexSearcher searcher = new IndexSearcher(sIndexLocation);
Hits oHitColl = searcher.Search(oParser.Parse(sSearchQuery));

Thanks folks
View this message in context: http://www.nabble.com/Wildcard-and-Literal-Searches-combined-tp18089950p18089950.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
groupjava-user @
postedJun 24, '08 at 12:29p
activeJun 25, '08 at 9:21p



site design / logo © 2022 Grokbase