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

Hoss Man commented on LUCENE-3273:
----------------------------------

I'm in favor of eliminating the QueryParser dependency, but i feel like this 
approach of adding things like "BooleanQueryBuilder" leads us down the road 
towards tests that are so verbose in query construction it will draw attention 
away from the important parts of the test -- doing something with those queres.

a while back when i wrote TestExplanations, i added a bunch of convenience 
methods for constructing esoteric queries that i couldn't get cleanly from the 
QueryParser (mainly spans) -- perhaps we should move towards generalizing that 
approach ... either in a Utility class where they can be staticly imported, or 
into LuceneTestCase?  These days we could even use vargs for things like 
Phrase, Boolean, and SpanNear queries (we weren't using Java5 when i wrote the 
existing ones)

That way instead of things like this...

{code}
PhraseQuery q = new PhraseQuery(); // Query "this hi this is a test is"
q.add(new Term("field", "hi"), 1);
q.add(new Term("field", "test"), 5);

assertEquals("field:\"? hi ? ? ? test\"", q.toString());
{code}

...we could have ...

{code}
Query q = phraseQ("field", null, "hi", null, null, null, "test");

assertEquals("field:\"? hi ? ? ? test\"", q.toString());
{code}

And instead of this...

{code}
public void testDMQ8() throws Exception {
  DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
  q.add(new BooleanQueryBuilder(FIELD)
      .addTermQuery("yy")
      .addQuery(QueryBuilderHelper.newTermQuery(FIELD, "w5", 100))
      .get());
  q.add(QueryBuilderHelper.newTermQuery(FIELD, "xx", 100000));
  qtest(q, new int[] { 0,2,3 });
}
{code}

...we could have...

{code}
public void testDMQ8() throws Exception {
  DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
  q.add(booleanQ(opt(termQ(FIELD, "yy")), 
                 opt(termQ(FIELD, "w5", 100))));
  q.add(termQ(FIELD, "xx", 100000));
  qtest(q, new int[] { 0,2,3 });
}
{code}



> Convert Lucene Core tests over to a simple MockQueryParser
> ----------------------------------------------------------
>
>                 Key: LUCENE-3273
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3273
>             Project: Lucene - Java
>          Issue Type: Sub-task
>          Components: core/other
>            Reporter: Chris Male
>         Attachments: LUCENE-3273.patch
>
>
> Most tests use Lucene Core's QueryParser for convenience.  We want to 
> consolidate it into a QP module which we can't have as a dependency.  We 
> should add a simple MockQueryParser which does String.split() on the query 
> string, analyzers the terms and builds a BooleanQuery if necessary.  Any more 
> complex Queries (such as phrases) should be done programmatically. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Reply via email to