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

John Wang commented on LUCENE-7597:
-----------------------------------

Made the following change to getMultiFieldQuery() method and seems to work as 
expected.

@Override
  protected Query getMultiFieldQuery(List<Query> queries) throws ParseException 
{
    if (queries.isEmpty()) {
      return null; // all clause words were filtered away by the analyzer.
    }
    BooleanQuery.Builder query = newBooleanQuery();
    query.setDisableCoord(true);
    BooleanClause.Occur occur = getDefaultOperator() == OR_OPERATOR ? 
BooleanClause.Occur.SHOULD : BooleanClause.Occur.MUST;    
    for (Query sub : queries) {
      query.add(sub, occur);
    }
    return query.build();
  }

> MultiFieldQueryParser does not honor default operator when there is a special 
> character
> ---------------------------------------------------------------------------------------
>
>                 Key: LUCENE-7597
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7597
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/queryparser
>    Affects Versions: 6.3
>            Reporter: John Wang
>
> simple code snippet
> MultiFieldQueryParser mp = new MultiFieldQueryParser(new String[]{"test"}, 
> new StandardAnalyzer());
>     mp.setDefaultOperator(Operator.AND);
>     System.out.println(mp.parse(qstring));
> if qstring is just 2 tokens, e.g: "you me", behavior is correct:
> +(test:you) +(test:me)
> now if qstring contains 2 tokens connected by a special char, e.g.: "you&me", 
> behavior is always OR, e.g.
> (test:you) (test:me)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to