-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Feature/implement complex queries #7350
Conversation
…guage. Signed-off-by: Dominik Voigt <[email protected]>
…m/JabRef/jabref into feature/implement-complex-queries
adapt tests accordingly
…/jabref into feature/implement-complex-queries
…m/JabRef/jabref into feature/implement-complex-queries
Fix IEEE tests. Extend IEEE capabilities. Create workarounds for some IEEE bugs
Fix some tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, you are now creating huge PRs am laufenden Fließband ;-)
After skimming, I've a few questions about the interface. It feels a bit more complicated than it should ideally be (but than again, that's always the case with these fetcher). Why does the following simplified call chain doesn't work:
search(String query)
parsing the user's query and callingsearch(parsedQuery)
(This method is mainly there to make testwriting simpler; the parsing should happen also in the GUI to give direct feeback when the query syntax is wrong)search(LuceneQuery query)
callinggetUrl
to obtain the url, then fetch result, parse it, cleanup, return result.getUrl(LuceneQuery query)
generating the url to call from the query. This could use a transformer to convert the query into a string query which is then added to the url viaaddParameter("query", transformedQuery);
. For REST-based API one should prefer to use something likeaddParameter("author", query.getAuthor());
instead.
*/ | ||
URL getURLForQuery(String query) throws URISyntaxException, MalformedURLException, FetcherException; | ||
URL getURLForQuery(String transformedQuery, AbstractQueryTransformer transformer) throws URISyntaxException, MalformedURLException, FetcherException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain why the getURL*
methods need to have the transformer as a second argument? It seems that each fetcher has it's own transformer, so why not use a simple class variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason for this is that some transformers require state that is used during query construction (See IEEE) and/or postprocessing (See ArXiv).
I now use a class variable and a reset method. :)
|
||
@Override | ||
public AbstractQueryTransformer getQueryTransformer() { | ||
return new ZbMathQueryTransformer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put these transformer classes as private inner classes. I think it's an implementation detail how the fetcher transforms the user-query to a query used in the url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm not sure how this would work with the inheritance of the transformer from the abstract implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That shouldn't be a problem. You just move the current code into the fetcher class.
The reason for this is that I wanted to keep the current fetcher method structure. |
Take for example the following (new) code:
This has the assumption that each fetcher has an API that supports searching via an extended So my proposal would be the following rewrite of the above code /**
* This method is used to send complex queries using fielded search.
*
* @param transformedQuery the search query defining all fielded search parameters
* @return a list of {@link BibEntry}, which are matched by the query (may be empty)
*/
List<BibEntry> performSearch(FetcherQuery query) throws FetcherException;
// In a Parser-Based fetcher this calls getUrlForQuery(query)
/**
* Looks for hits which are matched by the given free-text query.
*
* @param searchQuery query string that can be parsed into a complex search query
* @return a list of {@link BibEntry}, which are matched by the query (may be empty)
*/
default List<BibEntry> performSearch(String query) throws JabRefException {
return this.performSearch(FetcherQuery.parse(query));
}
//// Then in a fetcher
Url getUrlForQuery(FetcherQuery query) {
urlBuilder.addParamater("query", new xyzTransformer().transform(query))
// or
urlBuilder.addParamater("author", query.getAuthor())
} For flexibility, I would introduce a |
Okay, I adapted the code accordingly! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I like it a lot!
The idea behind the FetcherQuery
was to provide access to common query parameters that are context-specific (like start/end year, title, authors).
1330546
to
d40f640
Compare
* upstream/master: Bump archunit-junit5-api from 0.15.0 to 0.16.0 (#7407) Bump classgraph from 4.8.98 to 4.8.102 (#7401) Bump archunit-junit5-engine from 0.15.0 to 0.16.0 (#7402) Bump mariadb-java-client from 2.7.1 to 2.7.2 (#7406) Bump org.beryx.jlink from 2.23.2 to 2.23.3 (#7400) Bump checkstyle from 8.39 to 8.40 (#7404) Ignore codecov status for automerge Fixes issue of Changing font size makes font size field too small (#7398) fix "Alt + keyboard shortcuts do not work" (#7379) Fixed invisible file path in the dark theme (#7396) Fix File Filter and some layout issues (#7385) Feature/implement complex queries (#7350) Change format for study definition to yaml (#7126) Fix handling of URL in file field (#7347) Fix expansion of bracketed expressions in RegExpBasedFileFinder (#7338)
This PR introduces QueryTransformers for creating structured and fielded queries in the cross-library query language and transforming them into the library-specific query language.
Here a set of Transformers are included, and new transformers can easily be added by extending the
AbstractQueryTransformer
.Transformers are integrated into the default
performSearch
method of theSearchBasedFetcher
and all child classes.Additionally, this PR addresses some bugs in the fetcher tests.