1 5 package org.exoplatform.services.indexing; 6 7 import org.apache.lucene.analysis.Analyzer; 8 import org.apache.lucene.queryParser.QueryParser; 9 import org.apache.lucene.search.Query; 10 15 public class SingleFieldSearchInput implements SearchInput { 16 17 private String field_ ; 18 private String term_ ; 19 private boolean required_ = true ; 20 21 public SingleFieldSearchInput(String field) { 22 field_ = field ; 23 } 24 25 public SingleFieldSearchInput(String field, String term) { 26 field_ = field ; 27 term_ = term ; 28 } 29 30 public boolean isRequired() { return required_ ; } 31 public void setRequired(boolean b) { required_ = b ; } 32 33 public String getField() { return field_ ; } 34 35 public boolean hasTerm() { 36 return term_ != null && term_.length() > 0; 37 } 38 39 public String getTerm() { return term_ ; } 40 public void setTerm(String term) { term_ = term ; } 41 42 public Query getQuery(Analyzer analyzer) throws Exception { 43 return QueryParser.parse(term_ , field_, analyzer) ; 44 } 45 } | Popular Tags |