I don't think we will add this to the DSL, as I doubt we can rely on the stability and overall quality of "sandbox" code. We actually explicitly exclude this artifact from our transitive dependencies. That being said, if you want to rely on that code, you can still roll out your own "slow fuzzy query parser":
public final class SlowFuzzyQueryBuilder extends QueryBuilder {
private final int minimumSimilarity;
public FuzzyQueryBuilder(Analyzer analyzer, int minimumSimilarity) {
super( analyzer );
this.minimumSimilarity = minimumSimilarity;
}
@Override
protected Query newTermQuery(Term term) {
return new SlowFuzzyQuery( term, minimumSimilarity );
}
}
And get the custom analyzer from Hibernate Search:
Analyzer analyzer = fullTextSession.getSearchFactory().getAnalyzer( MyEntity.class );
(Or re-build the analyzer manually using org.apache.lucene.analysis.custom.CustomAnalyzer#builder()) Then just do this to create the Lucene query:
SlowFuzzyQueryBuilder builder = new SlowFuzzyQueryBuilder( analyzer, 4 );
Query luceneQuery = builder.createBooleanQuery( "field_name", "search terms" );
|