{
if ( JarFileContentsIndexCreator.FLD_CLASSNAMES.equals( indexerField ) )
{
String qpQuery = query.toLowerCase().replaceAll( "\\.", " " ).replaceAll( "/", " " );
// tokenization should happen against the field!
QueryParser qp = new QueryParser( Version.LUCENE_30, indexerField.getKey(), new NexusAnalyzer() );
qp.setDefaultOperator( Operator.AND );
return qp.parse( qpQuery );
}
else if ( indexerField.isKeyword() )
{
// no tokenization should happen against the field!
if ( query.contains( "*" ) || query.contains( "?" ) )
{
return new WildcardQuery( new Term( indexerField.getKey(), query ) );
}
else
{
BooleanQuery bq = new BooleanQuery();
Term t = new Term( indexerField.getKey(), query );
bq.add( new TermQuery( t ), Occur.SHOULD );
PrefixQuery pq = new PrefixQuery( t );
pq.setBoost( 0.8f );
bq.add( pq, Occur.SHOULD );
return bq;
}
}
else
{
// to save "original" query
String qpQuery = query;
// tokenization should happen against the field!
QueryParser qp = new QueryParser( Version.LUCENE_30, indexerField.getKey(), new NexusAnalyzer() );
qp.setDefaultOperator( Operator.AND );
// small cheap trick
// if a query is not "expert" (does not contain field:val kind of expression)
// but it contains star and/or punctuation chars, example: "common-log*"