*** QueryParser.jj.org Tue Jan 20 13:30:23 2004 --- QueryParser.jj Thu Jan 22 08:47:43 2004 *************** *** 239,245 **** // If this term is introduced by AND, make the preceding term required, // unless it's already prohibited ! if (conj == CONJ_AND) { BooleanClause c = (BooleanClause) clauses.elementAt(clauses.size()-1); if (!c.prohibited) c.required = true; --- 239,246 ---- // If this term is introduced by AND, make the preceding term required, // unless it's already prohibited ! if (conj == CONJ_AND && ! clauses.size() > 0 ) { // might be false if stop words are used... BooleanClause c = (BooleanClause) clauses.elementAt(clauses.size()-1); if (!c.prohibited) c.required = true; *************** *** 250,258 **** // unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b) // notice if the input is a OR b, first term is parsed as required; without // this modification a OR b would parsed as +a OR b ! BooleanClause c = (BooleanClause) clauses.elementAt(clauses.size()-1); ! if (!c.prohibited) ! c.required = false; } // We might have been passed a null query; the term might have been --- 251,261 ---- // unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b) // notice if the input is a OR b, first term is parsed as required; without // this modification a OR b would parsed as +a OR b ! if ( clauses.size() > 0 ) { // might be false if stop words are used... ! BooleanClause c = (BooleanClause) clauses.elementAt(clauses.size()-1); ! if (!c.prohibited) ! c.required = false; ! } } // We might have been passed a null query; the term might have been *************** *** 363,371 **** protected Query getBooleanQuery(Vector clauses) throws ParseException { BooleanQuery query = new BooleanQuery(); for (int i = 0; i < clauses.size(); i++) { ! query.add((BooleanClause)clauses.elementAt(i)); } return query; } --- 366,380 ---- protected Query getBooleanQuery(Vector clauses) throws ParseException { BooleanQuery query = new BooleanQuery(); + boolean empty = true; for (int i = 0; i < clauses.size(); i++) { ! BooleanClause clause = (BooleanClause)clauses.elementAt(i); ! if ( !clause.prohibited ) ! empty = false; ! query.add(clause); } + if ( empty ) + return null; return query; }