Project

General

Profile

Download (3.04 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.persistence.dao.common;
11

    
12
import java.util.List;
13

    
14
import eu.etaxonomy.cdm.model.common.CdmBase;
15
import eu.etaxonomy.cdm.persistence.query.OrderHint;
16

    
17
public interface ISearchableDao<T extends CdmBase> {
18

    
19
	/**
20
	 * Returns a count of T instances where entities match a given queryString (as interpreted by the Lucene QueryParser)
21
	 *
22
	 * @param clazz filter the results by class (or pass null to count all entities of type T)
23
	 * @param queryString
24
	 * @return a count of the matching entities
25
	 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
26
	 */
27
	public long count(Class<? extends T> clazz, String queryString);
28

    
29
	/**
30
	 * Returns a List of T instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
31
	 *
32
	 * @param clazz filter the results by class (or pass null to return all entities of type T)
33
	 * @param queryString
34
	 * @param pageSize The maximum number of entities returned (can be null for all matching entities)
35
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
36
	 * @param orderHints
37
	 *            Supports path like <code>orderHints.propertyNames</code> which
38
	 *            include *-to-one properties like createdBy.username or
39
	 *            authorTeam.persistentTitleCache
40
	 * @param propertyPaths properties to be initialized
41
	 * @return a List T instances
42
	 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
43
	 */
44
	public List<T> search(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
45
//	public <S extends T> List<S> search(Class<S> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
46

    
47
	/**
48
	 * Suggest a query that will return hits based upon an existing lucene query string (that is presumably misspelt and returns no hits)
49
	 * Used to implement "did you mean?"-type functionality using the lucene spellchecker.
50
	 *
51
	 * @param string Query string to check
52
	 * @return a suggested query string that will return hits or null if no such alternative spelling can be found.
53
	 */
54
	public String suggestQuery(String string);
55

    
56
	/**
57
	 * Removes all entities of type T from the index
58
	 */
59
	public void purgeIndex();
60

    
61
	/**
62
	 * Index all T entities currently in the database (useful in concert with purgeIndex() to (re-)create
63
	 * indexes or in the  case of corrupt indexes / mismatch between
64
	 * the database and the free-text indices)
65
	 */
66
	public void rebuildIndex();
67

    
68
	/**
69
	 * Calls optimize on the relevant index (useful periodically to increase response times on the free-text search)
70
	 */
71
	public void optimizeIndex();
72
}
(15-15/21)