lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Miller (JIRA)" <j...@apache.org>
Subject [jira] Updated: (LUCENE-861) Contrib queries package Query implementations do not override equals()
Date Fri, 10 Apr 2009 00:08:13 GMT

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

Mark Miller updated LUCENE-861:
-------------------------------

    Fix Version/s: 2.9

> Contrib queries package Query implementations do not override equals()
> ----------------------------------------------------------------------
>
>                 Key: LUCENE-861
>                 URL: https://issues.apache.org/jira/browse/LUCENE-861
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.1
>         Environment: All
>            Reporter: Antony Bowesman
>            Assignee: Mark Miller
>            Priority: Minor
>             Fix For: 2.9
>
>         Attachments: LUCENE-861.patch
>
>
> Query implementations should override equals() so that Query instances can be cached
and that Filters can know if a Query has been used before.  See the discussion in this thread.
> http://www.mail-archive.com/java-user@lucene.apache.org/msg13061.html
> Following 3 contrib Query implementations do no override equals()
> org.apache.lucene.search.BoostingQuery;
> org.apache.lucene.search.FuzzyLikeThisQuery;
> org.apache.lucene.search.similar.MoreLikeThisQuery;
> Test cases below show the problem.
> package com.teamware.office.lucene.search;
> import static org.junit.Assert.*;
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.index.Term;
> import org.apache.lucene.search.BoostingQuery;
> import org.apache.lucene.search.FuzzyLikeThisQuery;
> import org.apache.lucene.search.TermQuery;
> import org.apache.lucene.search.similar.MoreLikeThisQuery;
> import org.junit.After;
> import org.junit.Before;
> import org.junit.Test;
> public class ContribQueriesEqualsTest
> {
>     /**
>      * @throws java.lang.Exception
>      */
>     @Before
>     public void setUp() throws Exception
>     {
>     }
>     /**
>      * @throws java.lang.Exception
>      */
>     @After
>     public void tearDown() throws Exception
>     {
>     }
>     
>     /**
>      *  Show that the BoostingQuery in the queries contrib package 
>      *  does not implement equals() correctly.
>      */
>     @Test
>     public void testBoostingQueryEquals()
>     {
>         TermQuery q1 = new TermQuery(new Term("subject:", "java"));
>         TermQuery q2 = new TermQuery(new Term("subject:", "java"));
>         assertEquals("Two TermQueries with same attributes should be equal", q1, q2);
>         BoostingQuery bq1 = new BoostingQuery(q1, q2, 0.1f);
>         BoostingQuery bq2 = new BoostingQuery(q1, q2, 0.1f);
>         assertEquals("BoostingQuery with same attributes is not equal", bq1, bq2);
>     }
>     /**
>      *  Show that the MoreLikeThisQuery in the queries contrib package 
>      *  does not implement equals() correctly.
>      */
>     @Test
>     public void testMoreLikeThisQueryEquals()
>     {
>         String moreLikeFields[] = new String[] {"subject", "body"};
>         
>         MoreLikeThisQuery mltq1 = new MoreLikeThisQuery("java", moreLikeFields, new StandardAnalyzer());
>         MoreLikeThisQuery mltq2 = new MoreLikeThisQuery("java", moreLikeFields, new StandardAnalyzer());
>         assertEquals("MoreLikeThisQuery with same attributes is not equal", mltq1, mltq2);
>     }
>     /**
>      *  Show that the FuzzyLikeThisQuery in the queries contrib package 
>      *  does not implement equals() correctly.
>      */
>     @Test
>     public void testFuzzyLikeThisQueryEquals()
>     {
>         FuzzyLikeThisQuery fltq1 = new FuzzyLikeThisQuery(10, new StandardAnalyzer());
>         fltq1.addTerms("javi", "subject", 0.5f, 2);
>         FuzzyLikeThisQuery fltq2 = new FuzzyLikeThisQuery(10, new StandardAnalyzer());
>         fltq2.addTerms("javi", "subject", 0.5f, 2);
>         assertEquals("FuzzyLikeThisQuery with same attributes is not equal", fltq1, fltq2);
>     }
> }

-- 
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: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message