1 package org.apache.maven.repository.indexing.query;
3 import org.apache.lucene.index.Term;
4 import org.apache.lucene.queryParser.ParseException;
5 import org.apache.lucene.queryParser.QueryParser;
6 import org.apache.lucene.search.TermQuery;
7 import org.apache.maven.repository.indexing.RepositoryIndex;
10 * Copyright 2001-2005 The Apache Software Foundation.
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * http://www.apache.org/licenses/LICENSE-2.0
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
27 * Class to hold a single field search condition
29 * @author Edwin Punzalan
31 public class SinglePhraseQuery
41 * @param field the index field to search
42 * @param value the index value requirement
44 public SinglePhraseQuery( String field, String value )
51 * Method to retrieve the name of the index field searched
53 * @return the name of the index field
55 public String getField()
61 * Method to retrieve the value used in searching the index field
63 * @return the value to corresspond the index field
65 public String getValue()
70 public org.apache.lucene.search.Query createLuceneQuery( RepositoryIndex index )
73 org.apache.lucene.search.Query qry;
74 if ( index.isKeywordField( this.field ) )
76 Term term = new Term( this.field, this.value );
77 qry = new TermQuery( term );
81 QueryParser parser = new QueryParser( this.field, index.getAnalyzer() );
82 qry = parser.parse( this.value );