Hi Bernd,
I also searched for such a filter but did not found it.
Best regards
Karsten
P.S. I am using now this filter:
public class CutMaxLengthFilter extends TokenFilter {
public CutMaxLengthFilter(TokenStream in) {
this(in, DEFAULT_MAXLENGTH);
}
public CutMaxLengthFilter(TokenStream in, int maxLength) {
super(in);
this.maxLength = maxLength;
}
public static final int DEFAULT_MAXLENGTH = 15;
private final int maxLength;
private final CharTermAttribute termAtt =
addAttribute(CharTermAttribute.class);
@Override
public final boolean incrementToken() throws IOException {
if (!input.incrementToken()) {
return false;
}
int length = termAtt.length();
if (maxLength > 0 && length > maxLength) {
termAtt.setLength(maxLength);
}
return true;
}
}
with this factory
public class CutMaxLengthFilterFactory extends BaseTokenFilterFactory {
private int maxLength;
@Override
public void init(Map<String, String> args) {
super.init(args);
maxLength = getInt("maxLength",
CutMaxLengthFilter.DEFAULT_MAXLENGTH);
}
public TokenStream create(TokenStream input) {
return new CutMaxLengthFilter(input, maxLength);
}
}
-------- Original-Nachricht --------
> Datum: Mon, 08 Aug 2011 10:15:45 +0200
> Von: Bernd Fehling <[email protected]>
> An: [email protected]
> Betreff: string cut-off filter?
> Hi list,
>
> is there a string cut-off filter to limit the length
> of a KeywordTokenized string?
>
> So the string should not be dropped, only limitited to a
> certain length.
>
> Regards
> Bernd