You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2014/03/20 20:16:44 UTC

[jira] [Commented] (LUCENE-4890) QueryTreeBuilder.getBuilder() only finds interfaces on the most derived class

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

ASF subversion and git services commented on LUCENE-4890:
---------------------------------------------------------

Commit 1579717 from [~mikemccand] in branch 'dev/branches/lucene_solr_3_6'
[ https://svn.apache.org/r1579717 ]

LUCENE-4890: get this test passing again

> QueryTreeBuilder.getBuilder() only finds interfaces on the most derived class
> -----------------------------------------------------------------------------
>
>                 Key: LUCENE-4890
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4890
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/queryparser
>    Affects Versions: 2.9, 2.9.1, 2.9.2, 2.9.3, 2.9.4, 3.0, 3.0.1, 3.0.2, 3.0.3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.6.1, 3.6.2
>         Environment: Lucene 3.3.0 on Win32
>            Reporter: Philip Searle
>            Assignee: Adriano Crestani
>            Priority: Minor
>             Fix For: 3.6.3, 4.4, 5.0
>
>         Attachments: LUCENE-4890_2013_05_25.patch
>
>
> QueryBuilder implementations registered with QueryTreeBuilder.setBuilder() are not recognized by QueryTreeBuilder.getBuilder() if they are registered for an interface implemented by a superclass. Registering them for a concrete query node class or an interface implemented by the most-derived class do work.
> {code:title=example.java|borderStyle=solid}
> /* Our custom query builder */
> class CustomQueryTreeBuilder extends QueryTreeBuilder {
>   public CustomQueryTreeBuilder() {
>     /* Turn field:"value" into an application-specific object */
>     setBuilder(FieldQueryNode.class, new QueryBuilder() {
>       @Override
>       public Object build(QueryNode queryNode) {
>         FieldQueryNode node = (FieldQueryNode) queryNode;
>         return new ApplicationSpecificClass(node.getFieldAsString());
>       }
>     });
>     /* Ignore all other query node types */
>     setBuilder(QueryNode.class, new  QueryBuilder() {
>       @Override
>       public Object build(QueryNode queryNode) {
>         return null;
>       }
>     });
>   }
> }
> /* Assume this is in the main program: */
> StandardQueryParser queryParser = new StandardQueryParser();
> queryParser.setQueryBuilder(new CustomQueryTreeBuilder());
> /* The following line will throw an exception because it can't find a builder for BooleanQueryNode.class */
> Object queryObject = queryParser.parse("field:\"value\" field2:\"value2\"", "field");
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

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