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