16-Aug-05 (Created: 16-Aug-05) | More in 'Lucene'

lucene: Given a list of words get an or query to locate a similar document set


       public static Query getRelevanceQuerySimple(List wordList)
       {
          
          //Constructing a boolean query
          BooleanQuery bq = new BooleanQuery();

          //Setup reused query parameters
          boolean bNotRequired=false;
          boolean bNotProhibited = false;

          Iterator wordItr = wordList.iterator();
          while(wordItr.hasNext())
          {
             String word = (String)wordItr.next();
             //Setup a term query
             TermQuery tq = new TermQuery(new Term("content",word));
             //Add it with proper search criteria
             bq.add(tq,bNotRequired,bNotProhibited);
          }
          return bq;
       }//eof-function