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

add support to lucene module for converting a query to a Lucene QueryWrapperFilter #491

Closed
mirkosertic opened this issue Sep 7, 2013 · 6 comments
Milestone

Comments

@mirkosertic
Copy link

@mirkosertic mirkosertic commented Sep 7, 2013

It would be great to have an ability to convert a TypedQuery to a Lucene QueryWrapperFilter. This would enable us to convert queries with a "constant" and a "dynamic" part to a Filter for the "constant" conditions and reuse it between different filters. This would greatly improve query performance in Lucene4. The AbstractLuceneQuery. createQuery() Method is private, so i am not able to implement this functionality by subclassing or delegation.

@mirkosertic
Copy link
Author

@mirkosertic mirkosertic commented Sep 7, 2013

Another option could be to add something like a "const" method to a filter predicate. Then we can use the dsl to express the static and dynamic parts and QueryDSL could internally create a query with the corresponding filter.

@timowest
Copy link
Member

@timowest timowest commented Sep 8, 2013

AbstractLuceneQuery.createQuery() is private. Maybe filter access could be provided on the AbstractLuceneQuery level instead?

Something like this maybe

public Filter asFilter() {
    return new QueryWrapperFilter(createQuery());
}

or alternatively just make the access of createQuery public?

@mirkosertic
Copy link
Author

@mirkosertic mirkosertic commented Sep 8, 2013

The asFilter implementation looks pretty good. From a Lucene point of view we should only use filters if we want to reuse them, so probably it would make sense to always return a CachingWrapperFilter instance. For further enhancements it would be cool to have the createQuery() method with protected visibility, so subclasses can access it.

By the way: what would be the best way to create unit tests for TypedQueries? Should i rely on toString() or should i assert the created Lucene query?

@timowest
Copy link
Member

@timowest timowest commented Sep 8, 2013

By the way: what would be the best way to create unit tests for TypedQueries? Should i rely on toString() or should i assert the created Lucene query?

Probably assert the created Lucene query.

@mirkosertic
Copy link
Author

@mirkosertic mirkosertic commented Sep 8, 2013

So protected acces for createQuery() makes perfect sense, or even public access...

timowest added a commit that referenced this issue Sep 8, 2013
@timowest
Copy link
Member

@timowest timowest commented Oct 20, 2013

Released in 3.2.4

@timowest timowest closed this Oct 20, 2013
@timowest timowest added this to the 3.2.4 milestone Apr 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants