Goal
Approach
Design
There are several Lucene objects that need to be considered when decoupling Lucene from LexEVS. We will need to abstract this types when decoupling. Some of these Lucene objects include:
- AbstractLazyCodeHolderFactory
- org.apache.lucene.search.BooleanQuery;
- org.apache.lucene.search.Filter;
- org.apache.lucene.search.FilteredQuery;
- org.apache.lucene.search.Query;
- org.apache.lucene.search.ScoreDoc;
- org.apache.lucene.search.BooleanClause.Occur;
- org.compass.core.lucene.support.ChainedFilter;
- CodedNodeSetImpl
- org.apache.lucene.search.BooleanQuery;
- org.apache.lucene.search.MatchAllDocsQuery;
- org.apache.lucene.search.Query;
- org.apache.lucene.search.BooleanClause.Occur;
- AbstractLazyCodeHolderFactory. buildCodeHolderWithFilters()
- CodedNodeSetImpl.runPendingOps()
Different Lucene Query methods that could be pulled out of CodedNodeSetImpl and AbstractLazyCodeHolderFactory. These methods can be pushed into an implementation of the Query interface below. The interface will be used instead of calling Lucene directly.
//code decoupling // Interface for creating Queries public interface Query { // methods required for CodedNodeSetImpl public Query getCodingSchemeQuery(String uri, String internalVersionString); public Query getRestrictionQuery(Restriction restriction, String internalCodeSystemName, String internalVersionString); // methods required for AbstractLazyCodeHolderFactory private Query getBooleanQuery(List<Query> queries); public Query getFilteredQuery(List<Filter> filters, BooleanQuery combinedQuery, Filter chainedFilter); } // Lucene Implementation public class LuceneQuery implements Query { }
Interface for a ScoreDoc Factory. AbstractLazyCodeHolderFactory.buildCodeHolder is currently using ScoreDocs.
public interface ScoreDocFactory { List<ScoreDoc> getScoreDocs (EntityIndexService service, AbsoluteCodingSchemeVersionReference ref, List<BooleanQuery> combinedQuery,List<Query> bitSetQueries); }
Need to define different types of Queries and Filters. Create an abstract class for each of them. CodedNodeSetImpl and AbstractLazyCodeHolderFactory will not need to reference Lucene objects directly then.
// Potential abstract classes for defining different types of Lucene objects in a generic manner. public abstract class QueryType { } public abstract class FilterType { } public abstract class FilteredQuery { }