[ 
https://issues.apache.org/jira/browse/LUCENE-993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12986930#action_12986930
 ] 

Shai Erera commented on LUCENE-993:
-----------------------------------

That still happens and I agree this is a bug. According to MFQP.parse(), if you 
pass a query "q", some fields and their respective flags, the query will be 
parsed according to fields and flags. However, if you pass the query "f:query", 
then what happens is that the query is parsed and the flags applied to it, 
irregardless of what you specified. I think that what should happen is:
* If the query is not fielded, then apply the fields + flags as passed in.
* Otherwise, only apply the flags of the matching field, or don't apply them at 
all. E.g., if the query was "field:value" and the caller specified a flag for 
the field "field", then apply it, otherwise, leave it as-is.

That said though, should MFQP handle more complex queries, such as "somevalue 
f1:val f2:val (some OR more OR text)"?

Leaving it open because for the simple case (one fielded term), MFQP does not 
work as expected. Either we fix the bug, or document the limitation (e.g., 
"don't pass fielded terms to this QP").

> 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
>         Attachments: MultiFieldQueryParserBug.java
>
>
> Below, and attached, 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, and all MUST fields must be present.
> 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.SHOULD, 
> 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]

Reply via email to