[ 
https://issues.apache.org/jira/browse/LUCENE-7878?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jim Ferenczi updated LUCENE-7878:
---------------------------------
    Fix Version/s: 6.7
                   master (7.0)

> QueryParser AND default operator and MultiWords synonyms failed if keywords 
> exactly matches a synonym
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-7878
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7878
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/queryparser
>    Affects Versions: master (7.0), 6.6, 6.5.1
>         Environment: 1.8.0_131-b11 on Mac OS X
>            Reporter: Emmanuel Keller
>              Labels: multi-word, query-parser, synonyms
>             Fix For: master (7.0), 6.7
>
>         Attachments: LUCENE-7878.patch, LUCENE-7878.patch
>
>
> This issue is about using the QueryParser with MultiWordsSynonyms.
> To reproduce the bug:
> - Use AND as default operator
> - Use a query string which exactly matches one synonym.
> In short, the part of the query which handle the synonym lookup should keep a 
> "OR" relation between the synonyms, but it is translated as a "AND".
> If I parse: "guinea pig" which is a synonym of "cavy":
> Using default OR, I get something correct:
>     "(+guinea +pig) cavy"
> Note: I should probably better have ((+guinea +pic) cavy)
> Using AND as default operator, I get something wrong:
>     +(+guinea +pig) +cavy
> I was expected:
>     +((+guinea +pig) cavy)
> The relation between "guinea pig" and "cavy" is now a AND. It should be still 
> a OR because it is a synonym clause.
> To help understanding. If now I parse "guinea pig world"
> And I get the expected result:
>     +((+guinea +pig) cavy) +world
> The relation between "guinea pig" and "cavy" is a OR as expected (it is a 
> synonym), and the relation with "world" is AND as expected by the default 
> operator.
> Here is the additional unit test for, I hope it is pretty self-explanatory:
> org.apache.lucene.queryparser.classic.TestQueryParser
> {code:java}
> public void testDefaultOperatorWhenKeywordsMatchesExactlyOneSynonym() throws 
> ParseException {
>     // Using the default OR operator
>     QueryParser smart = new QueryParser("field", new Analyzer1());
>     smart.setSplitOnWhitespace(false);
>     smart.setDefaultOperator(Operator.OR);
>     assertEquals("(+guinea +pig) cavy", smart.parse("guinea 
> pig").toString("field"));
>     // Using the default AND operator
>     smart = new QueryParser("field", new Analyzer1());
>     smart.setSplitOnWhitespace(false);
>     smart.setDefaultOperator(Operator.AND);
>     assertEquals("+((+guinea +pig) cavy) +world", smart.parse("guinea pig 
> world").toString("field"));
>     // Using the default AND operator
>     smart = new QueryParser("field", new Analyzer1());
>     smart.setSplitOnWhitespace(false);
>     smart.setDefaultOperator(Operator.AND);
>     assertEquals("+((+guinea +pig) cavy)", smart.parse("guinea 
> pig").toString("field"));
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to