You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Trejkaz (JIRA)" <ji...@apache.org> on 2017/01/03 02:19:58 UTC

[jira] [Commented] (LUCENE-7616) QueryNode#toQueryString says it produces a string in the syntax understood by "the query parser", but cannot possibly know how

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

Trejkaz commented on LUCENE-7616:
---------------------------------

As an additional nasty point, sometimes this method is called from places like BooleanQueryNodeBuilder, where it goes into an error message to show the user. So this error message also shows the wrong syntax, but it also isn't immediately clear how a QueryNodeBuilder would know what syntax was used to create the QueryNode it has been passed...

> QueryNode#toQueryString says it produces a string in the syntax understood by "the query parser", but cannot possibly know how
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-7616
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7616
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/queryparser
>    Affects Versions: 6.3
>            Reporter: Trejkaz
>
> (Not an implementation "bug" so much as a design error, but working within the confines of JIRA here.)
> The "flexible" query parser framework allows custom query syntaxes to be implemented on top of the existing query node, processor and builder classes.
> Now, QueryNode has a toQueryString method which ostensibly converts the node back into a string appropriate for passing back through the parser. However, in practice, this method is implemented to return a syntax only appropriate for passing back to StandardQueryParser, *not* the parser you got the node from. The node itself has no idea what parser it came from, so it makes sense that this method could never work as currently designed.
> I don't really know what the right way to fix this is.
> Option A: Make QueryNode aware of which parser it came from, and add methods into the parser to format queries back into a string, so that this method can be implemented correctly. Sounds fine, except programmatically creating QueryNode objects directly becomes a hassle.
> Option B: Deprecate toQueryString and introduce a new SyntaxFormatter interface which converts QueryNode to CharSequence and provide an appropriate implementation for each existing SyntaxParser. Seems sensible and the most flexible option, but requires a lot of tiny classes to be implemented.
> Are there any other options?



--
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