There is an interesting post in Compass user forums, basically asking how to use external or specialized Lucene Query implementation. When building Compass, one of my aims was (and is) to allow Lucene users not to loose any of Lucene functionality. This includes specialized Lucene Query and Filter implementation.
Compass comes with query builders and query filter builders, allowing for a simplified programming model when constructing queries or query filters. If you have your own implementation of Lucene Query or Filter, you can construct CompassQuery or CompassQueryFilter implementation that wraps the actual Lucene implementation. Here is a code snippet that wraps a Lucene Query:
Query query = //build lucene query
InternalCompassSession internalCompassSession = (InternalCompassSession) session;
SearchEngineQuery searchEngineQuery =
new LuceneSearchEngineQuery((LuceneSearchEngine) internalCompassSession.getSearchEngine(), query);
return new DefaultCompassQuery(searchEngineQuery, internalCompassSession);
In the upcoming Compass version (0.9), Compass now comes with LuceneHelper class under the org.compass.core.lucene.util package, allowing to wrap Lucene query and filter more easily than using the above code.