add includeEmpty vocs (#2704)
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / common / ISearchableDao.java
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.model.occurrence.SpecimenOrObservationBase;
16 import eu.etaxonomy.cdm.persistence.query.OrderHint;
17
18 public interface ISearchableDao<T extends CdmBase> {
19
20 /**
21 * Returns a count of T instances where entities match a given queryString (as interpreted by the Lucene QueryParser)
22 *
23 * @param clazz filter the results by class (or pass null to count all entities of type T)
24 * @param queryString
25 * @return a count of the matching entities
26 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
27 */
28 public int count(Class<? extends T> clazz, String queryString);
29
30 /**
31 * Returns a List of T instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
32 *
33 * @param clazz filter the results by class (or pass null to return all entities of type T)
34 * @param queryString
35 * @param pageSize The maximum number of entities returned (can be null for all matching entities)
36 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
37 * @param orderHints
38 * Supports path like <code>orderHints.propertyNames</code> which
39 * include *-to-one properties like createdBy.username or
40 * authorTeam.persistentTitleCache
41 * @param propertyPaths properties to be initialized
42 * @return a List T instances
43 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
44 */
45 public List<T> search(Class<? extends T> 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 }