Implement fuzzy search functionality
Bug #669828 reported by
Morten Haraldsen
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
Medium
|
Timo Westkämper |
Bug Description
It is currently not possible to issue Lucene FuzzyQuery searches. I found a reference to a test-case for it but the functionality is not implemented yet. I like the syntax as found in the SimpleTest.java test in /tags/QUERYDSL_
<code>
// Fuzzy
// roam~ or roam~0.8
// c.ContactName.
// TODO
</code>
If anyone can tell me where to start I will be happy to implement it myself and provide a patch.
To post a comment you must log in.
Thanks for your bug report. You can wrap arbitrary Lucene Query instances as com.mysema. query.lucene. QueryElement instances.
I just commited the following utility class with supports the creation of fuzzy queries as Querydsl filters :
public final class LuceneUtils {
public static BooleanExpression fuzzyLike( Path<String> path, String value){ getMetadata( ).getExpression ().toString( ), value);
Term term = new Term(path.
return new QueryElement(new FuzzyQuery(term));
}
public static BooleanExpression fuzzyLike( Path<String> path, String value, float minimumSimilarity){ getMetadata( ).getExpression ().toString( ), value); ty));
Term term = new Term(path.
return new QueryElement(new FuzzyQuery(term, minimumSimilari
}
public static BooleanExpression fuzzyLike( Path<String> path, String value, float minimumSimilarity, int prefixLength){ getMetadata( ).getExpression ().toString( ), value);
Term term = new Term(path.
return new QueryElement(new FuzzyQuery(term, minimumSimilarity, prefixLength));
}
private LuceneUtils(){}
}
Feel free to suggest other additions.