Hello All, I am really sorry for not following the rules and bringing it to the top. It is important at the moment. Thanks.
On 11 February 2010 15:51, Smith G <gudumba.sm...@gmail.com> wrote: > Hello All, > I am writing some test cases for a custom-class which > modifies incoming TermQuery and adds some other Terms and returns a > BooleanQuery. As always I have used assertEquals(), which apparently > uses equals() method. I found out that following two queries are > different from each other if we use BooleanQuery.equals() if the > positions of the terms are inconsistent. > > For Ex : > > 1) BooleanQuery bq1 = new BooleanQuery(); > > bq1.add(new TermQuery(new Term("fiedl_1", "value_1")), > BooleanClause.Occur.MUST); > > bq1.add(new TermQuery(new Term("fiedl_2", "value_2")), > BooleanClause.Occur.MUST_NOT); > > > 2) BooleanQuery bq2 = new BooleanQuery(); > > bq2.add(new TermQuery(new Term("fiedl_2", "value_2")), > BooleanClause.Occur.MUST_NOT); > > bq2.add(new TermQuery(new Term("fiedl_1", "value_1")), > BooleanClause.Occur.MUST); > > > 3) BooleanQuery bq3 = new BooleanQuery(); > > bq3.add(new TermQuery(new Term("fiedl_1", "value_1")), > BooleanClause.Occur.MUST); > > bq3.add(new TermQuery(new Term("fiedl_2", "value_2")), > BooleanClause.Occur.MUST_NOT); > > I have observed following... > A) bq1.equals(bq2) returns FALSE; > B) bq1.equals(bq3) returns TRUE > > The issue is that we never know the order of terms populated in > the retunred BooleanQuery by the method. As according to the method > queries are not equal if the term's position changes, i.e I can not > prepare expected result. So I would be glad to know the point here? > "Are they really different?". If yes, Can you suggest me an > alternative which is conventionally used to test this kind of cases. > > (NOTE :: If you find any inconsistency in the field values (spellings, > etc) or in the code, Just assume that they are typing mistakes.) > Thanks. > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org