lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Muir (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-6245) ConstantScoreQuery etc have crazy toString()'s
Date Sat, 14 Feb 2015 15:16:12 GMT

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

Robert Muir commented on LUCENE-6245:
-------------------------------------

I didn't start on anything yet... I didn't know what other options we had. 

Its very surprising to me that Query.toString(String) is abstract but Query.toString() is
not final, to me that is the root problem and fixing that means introducing a break. Anything
else I think will be clumsy?

> ConstantScoreQuery etc have crazy toString()'s
> ----------------------------------------------
>
>                 Key: LUCENE-6245
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6245
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Robert Muir
>
> For backwards compatibility reasons, LUCENE-1518 gave Filter a default "crap" toString(String)
impl of getClass().getSimpleName(). I don't think we should do this. It causes problems e.g.
when filters are wrapped in ConstantScoreQuery or other places, because toString(String) does
the wrong thing.
> {code}
> Filter f = new MultiTermQueryWrapperFilter<WildcardQuery>(new WildcardQuery(new
Term("foo", "b*ar")));
>     
> System.out.println(f.toString()); // foo:b*ar
> System.out.println(f.toString("foo")); // MultiTermQueryWrapperFilter
> {code}
> Instead i think that impl should be removed (leaving it abstract), and Query.toString()
should be final for a hard break:
> {code}
>   /** Prints a query to a string, with <code>field</code> assumed to be the

>    * default field and omitted.
>    */
>   public abstract String toString(String field);
>   /** Prints a query to a string. */
>   @Override
>   public ****final**** String toString() {
>     return toString("");
>   }
> {code}
> having buggy toString's is worse than requiring a change in custom filters. It impacts
all users rather than just expert ones. Also by doing this, all the current toString bugs
in the codebase show up as compile errors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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


Mime
View raw message