MultiFieldQueryParser doesn't process search strings containing field references correctly when BooleanClause.Occur.MUST_NOT is used ------------------------------------------------------------------------------------------------------------------------------------
Key: LUCENE-993 URL: https://issues.apache.org/jira/browse/LUCENE-993 Project: Lucene - Java Issue Type: Bug Components: QueryParser, Search Affects Versions: 2.2 Reporter: Anthony Yeracaris Below is a complete java program illustrating this bug. In this program,I have an "allowed" field and a "restricted" field. The user is not permitted to search the "restricted" field. However, if the user provides the search string "allowed:value", then the MultiFieldQueryParser returns "+allowed:valu -allowed:valu", which has the effect of finding nothing. In the case the user provides a search string containing field references, I would expect the parser to use the field and occur arrays as constraints. In other words, if a the user mentions a field that has an occur of MUST_NOT, then that field should be elided from the search. At the end of parsing, there must be at least one search term, all MUST fields must have been mentioned. import org.apache.lucene.queryParser.MultiFieldQueryParser; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.analysis.snowball.SnowballAnalyzer; public class MultiFieldQueryParserBug { public static void main(String[] argv) { try { System.out.println(MultiFieldQueryParser.parse("allowed:value", new String[]{"allowed", "restricted"}, new BooleanClause.Occur[]{BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT}, new SnowballAnalyzer("English"))); // Output is: // +allowed:valu -allowed:valu } catch (ParseException e) { e.printStackTrace(); // generated } } } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]