You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Adriano Crestani (JIRA)" <ji...@apache.org> on 2013/05/25 06:19:20 UTC

[jira] [Assigned] (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:all-tabpanel ]

Adriano Crestani reassigned LUCENE-4890:
----------------------------------------

    Assignee: Adriano Crestani
    
> 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: 3.3
>         Environment: Lucene 3.3.0 on Win32
>            Reporter: Philip Searle
>            Assignee: Adriano Crestani
>            Priority: Minor
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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