Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't register custom QueryParser because the Query object is wrapped with NamedObjects just before parse [DATASOLR-452] #572

Closed
spring-projects-issues opened this issue Mar 7, 2018 · 4 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Mar 7, 2018

Takuya Iwanaga opened DATASOLR-452 and commented

We faced the issues that we can't register custom QueryParser.
More correctly saying, it doesn't work because the Query object is wrapped with NamedObjects just before parse and QueryParsers cannot choose the proper QueryParserPair.

example :
https://github.com/spring-projects/spring-data-solr/blob/e92e5c1/src/main/java/org/springframework/data/solr/core/SolrTemplate.java#L296

We've seen the issue's fixed for the versions like 2.1.10.RELEASE as shown below, but unfortunately it appears again for the latest versions like 3.x.x.RELEASE.

Version 2.1.10.RELEASE:
https://github.com/spring-projects/spring-data-solr/blob/4d536bd/src/main/java/org/springframework/data/solr/core/SolrTemplate.java#L1006

Version 3.0.5.RELEASE:
https://github.com/spring-projects/spring-data-solr/blob/e92e5c1/src/main/java/org/springframework/data/solr/core/SolrTemplate.java#L495

Is this the intended changes?
If so, please advise us the standard way to register our custom QueryParser.

Thanks


Affects: 3.0.5 (Kay SR5)

Issue Links:

  • DATASOLR-455 Open up AbstractQueryDecorator to allow access to decorated query

Backported to: 3.0.6 (Kay SR6)

6 votes, 6 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Mar 7, 2018

Christoph Strobl commented

thanks for bringing that up - I'll have a look at what happened there

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Mar 9, 2018

Takuya Iwanaga commented

Thank you for handling this issue, Christoph.
I noticed the changes you made in the commit log, and I found some issues still remain.

Let's say we want to add a custom query called MyQuery with MyQueryParser, it is a common use case that we add a specific field and/or a specific interface to MyQuery and construct SolrQuery instance with it in the MyQueryParser#constructSolrQuery like other Query such as DefualtQueryParser.
Here, we seem to have a problem, because the argument of QueryParser#constructorSolrQuery is the type of SolrDataQuery and the actual instance passed to the interface is wrapped one.
Therefore, there is no way to access MyQuery-specific fields and/or interface because AbstractQueryDecorator hides the actual Query.

SolrTemplate#custructQuery:
https://github.com/spring-projects/spring-data-solr/blob/master/src/main/java/org/springframework/data/solr/core/SolrTemplate.java#L528

DefaultQueryParser:
https://github.com/spring-projects/spring-data-solr/blob/master/src/main/java/org/springframework/data/solr/core/DefaultQueryParser.java#L99

AbstractQueryDecorator:
https://github.com/spring-projects/spring-data-solr/blob/master/src/main/java/org/springframework/data/solr/core/query/AbstractQueryDecorator.java#L35

Is there any solution?

Thanks.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 3, 2018

Christoph Strobl commented

I've opend DATASOLR-455 to open up AbstractQueryDecorator to expose the decorated Query via Query getDecoratedQuery(). Hope that's sufficient for your needs

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 11, 2018

Takuya Iwanaga commented

I've just tried, and it works perfectly well.
Thank you so much, Christoph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants