views:

71

answers:

1

Is there a simple way to add a fuzziness level to a user entered search query in lucene, I'd like to avoid having to parse their entered text if possible.

At present if they enter

green boxes

I use a multifield query parser with boosts which easily generates the following for example:

+(title:green^10 title:boxes^10) +(category:green^3 category:boxes^3)

What I'd like to then do is convert this to +(title:green^10~0.7 title:boxes^10~0.7) +(category:green^3~0.7 category:boxes^3~0.7)

It looks like I'd need to parse the query and add the fuzziness to each term but I was wondering if maybe there's a simple way to add the fuzziness? Thanks Mike

+1  A: 

Another way is to subclass and override MultiFieldQueryParser.getFieldQuery, having it call getFuzzyQuery.

Coady
Thanks, I'll give that a go,Mike
Mike d