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 + "*)";
}
else
{
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
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