View Javadoc
1   package org.apache.maven.index;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0    
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.lucene.queryparser.classic.ParseException;
23  import org.apache.lucene.search.Query;
24  import org.apache.maven.index.expr.SearchExpression;
25  
26  /**
27   * A component the creates Lucene Queries from "human written" queries, but also helps client applications to assemble
28   * proper queries for fields they want to search.
29   * 
30   * @author Tamas Cservenak
31   */
32  public interface QueryCreator
33  {
34      /**
35       * Performs a selection of the appropriate IndexerField belonging to proper Field.
36       * 
37       * @param field
38       * @param type
39       * @return
40       */
41      IndexerField selectIndexerField( Field field, SearchType type );
42  
43      /**
44       * Constructs query by parsing the query string, using field as default field. This method should be use to
45       * construct queries (single term or phrase queries) against <b>single field</b>.
46       * 
47       * @param field
48       * @param expression
49       * @return
50       * @throws ParseException if query parsing is unsuccessful.
51       */
52      Query constructQuery( Field field, SearchExpression expression )
53          throws ParseException;
54  
55      /**
56       * Constructs query by parsing the query string, using field as default field. This method should be use to
57       * construct queries (single term or phrase queries) against <b>single field</b>.
58       * 
59       * @param field
60       * @param query
61       * @param type
62       * @return
63       * @throws ParseException if query parsing is unsuccessful.
64       * @deprecated Use {@link #constructQuery(Field, SearchExpression)} instead.
65       */
66      Query constructQuery( Field field, String query, SearchType type )
67          throws ParseException;
68  
69      /**
70       * Deprecated. Avoid it's use! Constructs query against <b>single</b> field, using it's "best effort" approach to
71       * perform parsing, but letting caller to apply it's (usually wrong) knowledge about how field is indexed.
72       * 
73       * @param field
74       * @param query
75       * @return query if successfully parsed, or null.
76       * @deprecated Use {@link #constructQuery(Field, SearchExpression)} instead.
77       */
78      Query constructQuery( String field, String query );
79  
80  }