lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack Krupansky" <>
Subject Re: Query with phrases, wildcards and fuzziness
Date Wed, 22 May 2013 00:24:45 GMT
Just escape embedded spaces with a backslash.

-- Jack Krupansky

-----Original Message----- 
From: Ross Simpson
Sent: Tuesday, May 21, 2013 8:08 PM
Subject: Query with phrases, wildcards and fuzziness

Hi all,

I'm trying to create a fairly complex query, and having trouble constructing 

My index contains a TextField with place names as strings, e.g.:
Port Melbourne, VIC 3207

I'm using an analyzer with just KeywordTokenizer and LowerCaseFilter, so 
that my strings are not tokenized at all.

I want to support end-user searches like the following, and have them match 
that string above:
Port Melbourne, VIC 3207 (exact)
Port (prefix)
Port Mel (prefix, including a space)
Melbo (wildcard)
Melburne (fuzzy)

I'm trying to get away with not parsing the query myself, and just 
constructing something like this:
parser.parse( "(STRING^9) OR (STRING*^7) OR (*STRING*^5) OR (STRING~1^3) );

That doesn't seem to work, neither with QueryParser nor with 
ComplexPhraseQueryParser.  Specifically, I'm having trouble getting 
appropriate results when there's a space in the input string, notable with 
the wildcard match part (it ends up returning everything in the index).

Is my approach above possible?  I also have had a look at using specific 
Query implementations and combining them in a BooleanQuery, but I'm not 
quite sure how to replicate the "OR" behavior I want (from reading, 
Occur.SHOULD is not equivalent or "OR").

Any suggestions would be appreciated.


To unsubscribe, e-mail:
For additional commands, e-mail: 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message