}
/* Let Query-Parser handle this */
case CONTAINS:
case CONTAINS_NOT: {
Analyzer analyzer;
synchronized (this) {
analyzer = fIndexer.createAnalyzer();
}
QueryParser parser = new QueryParser(fieldname, analyzer);
parser.setAllowLeadingWildcard(true);
/* Prepare the value for parsing */
value = prepareForParsing(value);
/* Parse */
return parser.parse(value);
}
/* Wildcard-Query with trailing '*' */
case BEGINS_WITH: {
value = new StringBuilder(value.toLowerCase()).append("*").toString();
Term term = new Term(fieldname, value);
WildcardQuery query = new WildcardQuery(term);
return query;
}
/* Wildcard-Query with leading '*' */
case ENDS_WITH: {
value = new StringBuilder("*").append(value.toLowerCase()).toString();
Term term = new Term(fieldname, value);
return new WildcardQuery(term);
}
/* Fuzzy Query */
case SIMILIAR_TO: {
BooleanQuery similarityQuery = new BooleanQuery();
LowercaseWhitespaceAnalyzer analyzer = new LowercaseWhitespaceAnalyzer();
TokenStream tokenStream = analyzer.tokenStream(String.valueOf(IEntity.ALL_FIELDS), new StringReader(value));
Token token = null;
while ((token = tokenStream.next()) != null) {
Term term = new Term(fieldname, token.termText());
similarityQuery.add(new BooleanClause(new FuzzyQuery(term), Occur.MUST));
}