1
|
package eu.etaxonomy.cdm.api.service.search;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.util.List;
|
5
|
import java.util.Map;
|
6
|
|
7
|
import org.apache.lucene.index.CorruptIndexException;
|
8
|
import org.apache.lucene.search.TopDocs;
|
9
|
import org.apache.lucene.search.grouping.TopGroups;
|
10
|
import org.apache.lucene.util.BytesRef;
|
11
|
|
12
|
import eu.etaxonomy.cdm.model.CdmBaseType;
|
13
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
14
|
import eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao;
|
15
|
|
16
|
/**
|
17
|
* Interface for Builder classes which create {@link SearchResult} instances, from a list of LuceneSearch {@link TopDocs}.
|
18
|
*
|
19
|
* @author Andreas Kohlbecker
|
20
|
\* @since Jan 6, 2012
|
21
|
*
|
22
|
*/
|
23
|
public interface ISearchResultBuilder {
|
24
|
|
25
|
|
26
|
/**
|
27
|
* Creates a <code>List</code> of <code>SearchResult</code> entities from the supplied <code>TopDocs</code>.
|
28
|
* The firts Cdm enitity id found in the specified <code>idFields</code> of the Lucene documents will be used to load
|
29
|
* the referenced Cdm entities into the <code>SearchResult</code>s.
|
30
|
*
|
31
|
* @param topGroupsResultSet
|
32
|
* @param highlightFields
|
33
|
* @param dao
|
34
|
* @param idFields a map of class names as key and entity id fields as values
|
35
|
* @param propertyPaths
|
36
|
* @return
|
37
|
* @throws CorruptIndexException
|
38
|
* @throws IOException
|
39
|
*/
|
40
|
public abstract <T extends CdmBase> List<SearchResult<T>> createResultSet(TopGroups<BytesRef> topGroupsResultSet,
|
41
|
String[] highlightFields, ICdmEntityDao<T> dao, Map<CdmBaseType, String> idFields, List<String> propertyPaths) throws CorruptIndexException, IOException;
|
42
|
|
43
|
/**
|
44
|
* Creates a <code>List</code> of <code>SearchResult</code> entities from the supplied <code>TopDocs</code>.
|
45
|
* The first Cdm enitity id found in the specified <code>idFields</code> of the Lucene documents will be used to load
|
46
|
* the referenced Cdm entities into the <code>SearchResult</code>s.
|
47
|
*
|
48
|
* @param topDocs
|
49
|
* @param highlightFields
|
50
|
* @param dao
|
51
|
* @param idFields a map of class names as key and entity id fields as values
|
52
|
* @param propertyPaths
|
53
|
* @return
|
54
|
* @throws CorruptIndexException
|
55
|
* @throws IOException
|
56
|
*/
|
57
|
public <T extends CdmBase> List<SearchResult<T>> createResultSet(TopDocs topDocs,
|
58
|
String[] highlightFields, ICdmEntityDao<T> dao, Map<CdmBaseType, String> idFields, List<String> propertyPaths) throws CorruptIndexException, IOException;
|
59
|
|
60
|
/**
|
61
|
* Creates a <code>List</code> of <code>DocumentSearchResult</code> entities from the supplied <code>TopDocs</code>.
|
62
|
* This method can be used for building index-only results.
|
63
|
*
|
64
|
* @param topDocs
|
65
|
* @param highlightFields
|
66
|
* @return
|
67
|
* @throws CorruptIndexException
|
68
|
* @throws IOException
|
69
|
*/
|
70
|
public List<DocumentSearchResult> createResultSet(TopDocs topDocs, String[] highlightFields) throws CorruptIndexException, IOException;
|
71
|
|
72
|
|
73
|
}
|