KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > search > LuceneCocoonSearcher


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.search;
17
18 import org.apache.avalon.framework.component.Component;
19 import org.apache.cocoon.ProcessingException;
20 import org.apache.lucene.analysis.Analyzer;
21 import org.apache.lucene.search.Hits;
22 import org.apache.lucene.search.Query;
23 import org.apache.lucene.store.Directory;
24
25
26 /**
27  * The avalon behavioural component interface of a searcher.
28  * <p>
29  * This component defines an interface for searching.
30  * The idea is to abstract the process of searching having a query string,
31  * and an index, and generating hits which matches the query string in the index.
32  * </p>
33  *
34  * @author <a HREF="mailto:berni_huber@a1.net">Bernhard Huber</a>
35  * @version CVS $Id: LuceneCocoonSearcher.java 47285 2004-09-27 12:52:44Z cziegeler $
36  */

37 public interface LuceneCocoonSearcher extends Component
38 {
39     /**
40      * The ROLE name of this avalon component.
41      * <p>
42      * Its value if the FQN of this interface,
43      * ie. <code>org.apache.cocoon.components.search.LuceneCocoonSearcher</code>.
44      * </p>
45      *
46      * @since
47      */

48     String JavaDoc ROLE = "org.apache.cocoon.components.search.LuceneCocoonSearcher";
49
50
51     /**
52      * Sets the analyzer attribute of the LuceneCocoonSearcher object
53      * <p>
54      * The analyzer determines the tokenization of the query,
55      * and strategy of matching.
56      * </p>
57      * <p>
58      * The analyzer class defined here should be equivalent to the analyzer
59      * class used when creating the index used for searching.
60      * </p>
61      *
62      * @param analyzer The new analyzer value
63      * @since
64      */

65     void setAnalyzer(Analyzer analyzer);
66
67
68     /**
69      * Gets the analyzer attribute of the LuceneCocoonSearcher object
70      * <p>
71      * The analyzer determines the tokenization of the query,
72      * and strategy of matching.
73      * </p>
74      * <p>
75      * The analyzer class defined here should be equivalent to the analyzer
76      * class used when creating the index used for searching.
77      * </p>
78      *
79      * @since 2.1.6
80      */

81     Analyzer getAnalyzer();
82
83     /**
84      * Sets the directory attribute of the LuceneCocoonSearcher object
85      * <p>
86      * The directory specifies the directory used for looking up the
87      * index. It defines the physical place of the index
88      * </p>
89      *
90      * @param directory The new directory value
91      * @since
92      */

93     void setDirectory(Directory directory);
94
95
96     /**
97      * Search a query-string, returning zero, or more hits.
98      * <p>
99      * </p>
100      *
101      * @param query_string A query string parsable by a query parser.
102      * @param default_field The default field of the query string.
103      * @return Hits zero or more hits matching the query string
104      * @exception ProcessingException throwing due to processing errors while
105      * looking up the index directory, parsing the query string, generating the hits.
106      * @since
107      */

108     Hits search(String JavaDoc query_string, String JavaDoc default_field) throws ProcessingException;
109
110     /**
111      * Search using a Lucene Query object, returning zero, or more hits.
112      * <p>
113      * </p>
114      *
115      * @param query A lucene query
116      * @return Hits zero or more hits matching the query string
117      * @exception ProcessingException throwing due to processing errors while
118      * looking up the index directory, parsing the query string, generating the hits.
119      * @since 2.1.6
120      */

121     Hits search(Query query) throws ProcessingException;
122 }
123
124
Popular Tags