lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Pryor <>
Subject Suffix query
Date Thu, 24 Jun 2004 15:29:26 GMT
 I have read up on the negative aspects of a SuffixQuery class. Be these as
they may, a situation came up where one is required for an application I'm
working on, so I started with the PrefixQuery class and modified it to match
suffixes instead. The relevant method that changed was the rewrite() method:

public Query rewrite(IndexReader reader) throws IOException 
	BooleanQuery query = new BooleanQuery();
	Term startTerm = new Term(suffix.field(), "");
	TermEnum enumerator = reader.terms(startTerm);
  		String suffixText = suffix.text();
  		String suffixField = suffix.field();
			Term term = enumerator.term();
			if (term != null && term.field() != suffixField)
			if (term != null &&
	  			TermQuery tq = new TermQuery(term);	  //
found a match
	  			tq.setBoost(getBoost());              // set
the boost
	  			query.add(tq, false, false);		  //
add to query
  		while (;
	return query;

Questions: How na´ve is this implementation? How bad will performance be on
a large index, and is there a more efficient way to do this?

Thanks for advice,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message