2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.persistence
.dao
.common
;
12 import java
.util
.List
;
14 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
15 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
16 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
18 public interface ISearchableDao
<T
extends CdmBase
> {
21 * Returns a count of T instances where entities match a given queryString (as interpreted by the Lucene QueryParser)
23 * @param clazz filter the results by class (or pass null to count all entities of type T)
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>
28 public int count(Class
<?
extends T
> clazz
, String queryString
);
31 * Returns a List of T instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
33 * @param clazz filter the results by class (or pass null to return all entities of type T)
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)
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>
45 public List
<T
> search(Class
<?
extends T
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
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.
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.
54 public String
suggestQuery(String string
);
57 * Removes all entities of type T from the index
59 public void purgeIndex();
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)
66 public void rebuildIndex();
69 * Calls optimize on the relevant index (useful periodically to increase response times on the free-text search)
71 public void optimizeIndex();