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 21 public class QueryWordsExactPhrase extends QueryWordsToken { 22 private List words; 23 public QueryWordsExactPhrase() { 24 super(QueryWordsToken.EXACT_PHRASE, ""); words = new ArrayList (); 26 } 27 public void addWord(String word) { 28 words.add(word); 29 if (words.size() <= 1) 30 value = word; 31 else 32 value += " " + word; } 34 public List getWords() { 35 return words; 36 } 37 40 public Query createLuceneQuery(String field, float boost) { 41 PhraseQuery q = new PhraseQuery(); 42 for (Iterator it = getWords().iterator(); it.hasNext();) { 43 String word = (String ) it.next(); 44 Term t = new Term("exact_" + field, word); q.add(t); 46 q.setBoost(boost); 47 } 48 return q; 49 } 50 } 51 | Popular Tags |