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
Make ParseContext's IndexQueryParserService accessible #8248
Comments
The other "possible" workaround to inject IndexQueryParserService by @Inject into my own query parser does not work (circular dependency). |
why not just expose a getter for |
@kimchy thats of course the easy thing, as I said :-) My idea here was to make the common case "parse some other query in context of current ParseContext" easier: The same code is duplicated over and over. Maybe add something like ParseContext#parseQueryInCurrentContext(BytesReference), a setup like parseInnerQuery() - just cloning itsself. By that it could reused in WrapperQueryParser, WrapperFilterParser, and TemplateQueryParser - and for my case. |
The repetition is not terrible if you create a new instance of the Regardless, I don't see a reason why we can't expose the |
I am fine with exposing that! Add a getter and change the field to private final. |
@uschindler want to send a pull request? |
Can do! |
I have the following problem writing an own query parser from my own package:
My query parser has to internally create another Elasticsaearch query and parse it (which is actually a workaround: I need to create a MoreLikeThis query, but I dont want to replicate all code to generate the native Lucene Query). So I use MoreLikeThisQueryBuilder to create a BytesReference of the newly constructed query, so I can parse it to a Lucene Query.
Of course I cannot do the parseContext.parseInnerQuery, because the newly constructed query is in a separate BytesReference. Instead I do the same trick like WrappedQuery:
The problem is now: I need to clone the QueryParseContext. WrappedQueryParser just creates a new instance, but it needs the index name (easy to get) and IndexQueryParserService. Unfortunately, the latter is package private.
I would be happy if this could be solved. As this above stuff is used quite often, I think the best solution would be to allow to clone ParseContext or add a method to create a new one from an existion one (copy constructor). The other way would be to make the field accessible.
The current workaround is to use reflection to get the field...
The text was updated successfully, but these errors were encountered: