1 11 package org.eclipse.help.internal.search; 12 import java.util.ArrayList ; 13 import java.util.Iterator ; 14 import java.util.List ; 15 16 import org.apache.lucene.index.*; 17 import org.apache.lucene.search.*; 18 22 public class QueryWordsPhrase extends QueryWordsToken { 23 private List words; 24 public QueryWordsPhrase() { 25 super(QueryWordsToken.PHRASE, ""); words = new ArrayList (); 27 } 28 public void addWord(String word) { 29 words.add(word); 30 if (words.size() <= 1) 31 value = word; 32 else 33 value += " " + word; } 35 public List getWords() { 36 return words; 37 } 38 41 public Query createLuceneQuery(String field, float boost) { 42 PhraseQuery q = new PhraseQuery(); 43 for (Iterator it = getWords().iterator(); it.hasNext();) { 44 String word = (String ) it.next(); 45 Term t = new Term(field, word); 46 q.add(t); 47 q.setBoost(boost); 48 } 49 return q; 50 } 51 } 52 | Popular Tags |