merging delete functionality into trunk
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / search / ILuceneIndexToolProvider.java
1 // $Id$
2 /**
3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.api.service.search;
11
12 import org.apache.lucene.analysis.Analyzer;
13 import org.apache.lucene.index.IndexReader;
14 import org.apache.lucene.queryParser.QueryParser;
15 import org.hibernate.search.indexes.IndexReaderAccessor;
16
17 import eu.etaxonomy.cdm.model.common.CdmBase;
18
19 /**
20 * @author a.kohlbecker
21 * @date Sep 18, 2013
22 *
23 */
24 public interface ILuceneIndexToolProvider {
25
26 /**
27 * @return the IndexReader suitable for the lucene index of the given
28 * <code>clazz</code>
29 */
30 public abstract IndexReader getIndexReaderFor(Class<? extends CdmBase> clazz);
31
32 /**
33 * Either creates a new QueryParser or returns the QueryParser which has
34 * been created before for the specified class. The QueryParsers per CdmBase
35 * type are cached in a Map.
36 *
37 * @return the QueryParser suitable for the lucene index of the given
38 * <code>clazz</code>
39 */
40 public abstract QueryParser getQueryParserFor(Class<? extends CdmBase> clazz);
41
42 /**
43 * <b>WARING</b> The implementation of this method might return an Analyzer
44 * which is not suitable for all fields of the lucene document. This method
45 * internally uses the simplified method from {@link {
46 * @link org.hibernate.search.SearchFactory#getAnalyzer(Class)}
47 *
48 * @return the Analyzer suitable for the lucene index of the given
49 * <code>clazz</code>
50 */
51 public abstract Analyzer getAnalyzerFor(Class<? extends CdmBase> clazz);
52
53 /**
54 * Creates new QueryFactory for the specified Cdm type.
55 *
56 * @return A new QueryFactory suitable for the lucene index of the given
57 * <code>clazz</code>
58 */
59 public abstract QueryFactory newQueryFactoryFor(Class<? extends CdmBase> clazz);
60
61 /**
62 * @return the IndexReaderAccessor from the SearchFactory
63 */
64 public abstract IndexReaderAccessor getIndexReaderAccessor();
65
66 }