Lucene QueryParser needed to work with a Custom Analyzer that has a stop filter and porterstemfilter

With QueryParser, the glass filter does not work, and with AnalyzingQueryParser, the stop filter is not effective.

Is my observation correct? How to solve this problem?

Update So, some code experiments. AnalyzingQueryParser does not allow stopfilter, and QueryParser does not allow porterstemmerfilter with fuzzysearches.

So I need a QueryParser that allows fuzzy searches along with support for porterstemfilter and stopfilter.

+5
source share
1 answer

QueryParser , . StopAnalyzer AnalyzingQueryParser:

Analyzer analyzer1 = new StopAnalyzer(Version.LUCENE_30, ImmutableSet.of("foo", "bar", "blop"));
QueryParser qp = new AnalyzingQueryParser(Version.LUCENE_30, "field", analyzer1);
Query q = qp.parse("foobar foo bar blop hello");
System.out.println("query  " + q);

q = qp.parse("foobar~ foo~ bar~ hell~");
System.out.println("query  " + q);

: field: foobar field: hello field: foobar ~ 0.5 hell ~ 0.5. lucene 3.0.3, , . , , . , , :

@Override
protected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException {
    return super.getFuzzyQuery(field, termStr, minSimilarity);
}

@Override
protected Query getWildcardQuery(String field, String termStr) throws ParseException {
    return super.getWildcardQuery(field, termStr);
}
0

All Articles